aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/requirements
diff options
context:
space:
mode:
authorMike McQuaid2014-01-28 19:08:23 +0100
committerMike McQuaid2014-01-29 17:49:57 +0100
commit9ead3a1b08988f55ce07c556a12fc67d9d4c2f20 (patch)
tree59c3cce75c94c7a8fd79a514195eedf12c5a572b /Library/Homebrew/requirements
parent1303b35bfaf5454dc3c04cb7c43fca5d6d358f9b (diff)
downloadhomebrew-9ead3a1b08988f55ce07c556a12fc67d9d4c2f20.tar.bz2
python_dependency: cleanup and fix build env.
* Only set PYTHONPATH for Python 2. * Set the Python binary for superenv. References #24842. Closes #26197. Closes #26216. Closes #26218. Closes #26228.
Diffstat (limited to 'Library/Homebrew/requirements')
-rw-r--r--Library/Homebrew/requirements/python_dependency.rb30
1 files changed, 25 insertions, 5 deletions
diff --git a/Library/Homebrew/requirements/python_dependency.rb b/Library/Homebrew/requirements/python_dependency.rb
index 58ca58670..5fe51efda 100644
--- a/Library/Homebrew/requirements/python_dependency.rb
+++ b/Library/Homebrew/requirements/python_dependency.rb
@@ -4,23 +4,43 @@ class PythonDependency < Requirement
fatal true
satisfy :build_env => false do
- which 'python'
+ which_python
+ end
+
+ def which_python
+ @which_python ||= which python_binary
end
def modify_build_environment
- ENV['PYTHONPATH'] = "#{HOMEBREW_PREFIX}/lib/python2.7/site-packages"
+ if python_binary == 'python'
+ ENV['PYTHONPATH'] = "#{HOMEBREW_PREFIX}/lib/python2.7/site-packages"
+ end
+
+ if !system_python? && which_python
+ ENV.prepend_path 'PATH', which_python.dirname
+ end
end
- # Deprecated
- def to_s
+ def system_python?
+ which_python.to_s == "/usr/bin/#{python_binary}"
+ end
+
+ def python_binary
'python'
end
+
+ # Deprecated
+ alias_method :to_s, :python_binary
end
class Python3Dependency < PythonDependency
default_formula 'python3'
satisfy :build_env => false do
- which 'python3'
+ which_python
+ end
+
+ def python_binary
+ 'python3'
end
end