ENV/super: add Python's libexec/"bin" directory when applicable

When Homebrew/homebrew-core#107517 is merged, builds will no longer be
able to find `python@3.9` as `python3`. This is also what is likely to
happen to `python@3.10` when we add a `python@3.11`.

This is likely to break many builds, so let's make sure they can keep
finding a `python3` for formulae that don't have a dependency on the
latest Python3.

This is arguably something we should've done earlier: it also means that
builds that go looking for an unversioned `python` end up finding our
Python3 (whenever present in the build environment) instead of, say,
`/usr/bin/python` which is typically Python2.
This commit is contained in:
Carlo Cabrera 2022-08-10 22:51:44 +08:00
parent 7fcc30c56b
commit 999623b45d
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
2 changed files with 4 additions and 2 deletions

View File

@ -125,8 +125,10 @@ module Superenv
sig { returns(T::Array[Pathname]) } sig { returns(T::Array[Pathname]) }
def homebrew_extra_paths def homebrew_extra_paths
[] deps.select { |d| d.name.match? Version.formula_optionally_versioned_regex(:python) }
.map { |d| d.opt_libexec/"bin" }
end end
alias generic_homebrew_extra_paths homebrew_extra_paths
sig { returns(T.nilable(PATH)) } sig { returns(T.nilable(PATH)) }
def determine_path def determine_path

View File

@ -27,7 +27,7 @@ module Superenv
end end
def homebrew_extra_paths def homebrew_extra_paths
paths = [] paths = generic_homebrew_extra_paths
paths += %w[binutils make].map do |f| paths += %w[binutils make].map do |f|
bin = Formulary.factory(f).opt_bin bin = Formulary.factory(f).opt_bin
bin if bin.directory? bin if bin.directory?