python_dependency: cleanup and fix build env.
* Only set PYTHONPATH for Python 2. * Set the Python binary for superenv. References Homebrew/homebrew#24842. Closes Homebrew/homebrew#26197. Closes Homebrew/homebrew#26216. Closes Homebrew/homebrew#26218. Closes Homebrew/homebrew#26228.
This commit is contained in:
parent
cf8cd9d4c2
commit
ed53bb333b
@ -4,23 +4,43 @@ class PythonDependency < Requirement
|
|||||||
fatal true
|
fatal true
|
||||||
|
|
||||||
satisfy :build_env => false do
|
satisfy :build_env => false do
|
||||||
which 'python'
|
which_python
|
||||||
|
end
|
||||||
|
|
||||||
|
def which_python
|
||||||
|
@which_python ||= which python_binary
|
||||||
end
|
end
|
||||||
|
|
||||||
def modify_build_environment
|
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
|
||||||
|
|
||||||
|
def system_python?
|
||||||
|
which_python.to_s == "/usr/bin/#{python_binary}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def python_binary
|
||||||
|
'python'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deprecated
|
# Deprecated
|
||||||
def to_s
|
alias_method :to_s, :python_binary
|
||||||
'python'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class Python3Dependency < PythonDependency
|
class Python3Dependency < PythonDependency
|
||||||
default_formula 'python3'
|
default_formula 'python3'
|
||||||
|
|
||||||
satisfy :build_env => false do
|
satisfy :build_env => false do
|
||||||
which 'python3'
|
which_python
|
||||||
|
end
|
||||||
|
|
||||||
|
def python_binary
|
||||||
|
'python3'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user