Prefer newer versions of Python

Some formulae declare multiple Python dependencies, and they can appear
in any order in the `deps` array. Let's make sure to prefer the newest
one when adding their `libexec/"bin"` directory to `PATH`.
This commit is contained in:
Carlo Cabrera 2022-08-15 18:18:21 +08:00
parent 999623b45d
commit 8064a39c18
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -125,7 +125,10 @@ module Superenv
sig { returns(T::Array[Pathname]) }
def homebrew_extra_paths
# Reverse sort by version so that we prefer the newest when there are multiple.
deps.select { |d| d.name.match? Version.formula_optionally_versioned_regex(:python) }
.sort_by(&:version)
.reverse
.map { |d| d.opt_libexec/"bin" }
end
alias generic_homebrew_extra_paths homebrew_extra_paths