aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/requirements/python_requirement.rb
diff options
context:
space:
mode:
authorMisty De Meo2015-08-09 19:12:54 -0700
committerMisty De Meo2015-08-10 07:30:41 -0700
commit6b1ce9827e857ae5c4b1dc8436d174a7bb4019a0 (patch)
tree80df84d977ec85e3ebc67288c103aea676157ab0 /Library/Homebrew/requirements/python_requirement.rb
parentfac17e8459c193e40144c5e7875f5b634d8af9a0 (diff)
downloadbrew-6b1ce9827e857ae5c4b1dc8436d174a7bb4019a0.tar.bz2
PythonRequirement: don't blindly use first Python in PATH
Fixes Homebrew/homebrew#42461.
Diffstat (limited to 'Library/Homebrew/requirements/python_requirement.rb')
-rw-r--r--Library/Homebrew/requirements/python_requirement.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/Library/Homebrew/requirements/python_requirement.rb b/Library/Homebrew/requirements/python_requirement.rb
index 1fb1045f0..adf13488c 100644
--- a/Library/Homebrew/requirements/python_requirement.rb
+++ b/Library/Homebrew/requirements/python_requirement.rb
@@ -19,13 +19,17 @@ class PythonRequirement < Requirement
end
env do
- if system_python?
- if python_binary == "python"
- version = python_short_version
- ENV["PYTHONPATH"] = "#{HOMEBREW_PREFIX}/lib/python#{version}/site-packages"
- end
- elsif which_python
+ short_version = python_short_version
+
+ if !system_python? && short_version == Version.new("2.7")
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