PythonRequirement: don't blindly use first Python in PATH

Fixes Homebrew/homebrew#42461.
This commit is contained in:
Misty De Meo 2015-08-09 19:12:54 -07:00
parent fac17e8459
commit 6b1ce9827e

View File

@ -19,13 +19,17 @@ class PythonRequirement < Requirement
end end
env do env do
if system_python? short_version = python_short_version
if python_binary == "python"
version = python_short_version if !system_python? && short_version == Version.new("2.7")
ENV["PYTHONPATH"] = "#{HOMEBREW_PREFIX}/lib/python#{version}/site-packages"
end
elsif which_python
ENV.prepend_path "PATH", which_python.dirname ENV.prepend_path "PATH", which_python.dirname
# Homebrew Python should take precedence over older Pythons in the PATH
elsif short_version != Version.new("2.7")
ENV.prepend_path "PATH", Formula["python"].opt_bin
end
if python_binary == "python"
ENV["PYTHONPATH"] = "#{HOMEBREW_PREFIX}/lib/python#{version}/site-packages"
end end
end end