Merge pull request #3577 from MikeMcQuaid/python_requirement_tweaks

python_requirement: various tweaks/fixes.
This commit is contained in:
Mike McQuaid 2017-12-14 10:10:06 +00:00 committed by GitHub
commit c912d268f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,15 +7,12 @@ class PythonRequirement < Requirement
satisfy build_env: false do satisfy build_env: false do
python = which_python python = which_python
next unless python next unless python
version = python_short_version next unless short_version
next unless version
# Always use Python 2.7 for consistency on older versions of Mac OS X. # Always use Python 2.7 for consistency on older versions of Mac OS X.
version == Version.create("2.7") short_version == Version.create("2.7")
end end
env do env do
short_version = python_short_version
if !system_python? && short_version == Version.create("2.7") if !system_python? && short_version == Version.create("2.7")
ENV.prepend_path "PATH", which_python.dirname ENV.prepend_path "PATH", which_python.dirname
end end
@ -24,10 +21,14 @@ class PythonRequirement < Requirement
ENV.prepend_path "PATH", Formula["python"].opt_bin ENV.prepend_path "PATH", Formula["python"].opt_bin
ENV.prepend_path "PATH", Formula["python"].opt_libexec/"bin" ENV.prepend_path "PATH", Formula["python"].opt_libexec/"bin"
ENV["PYTHONPATH"] = "#{HOMEBREW_PREFIX}/lib/python#{short_version}/site-packages" if system_python?
ENV["PYTHONPATH"] = "#{HOMEBREW_PREFIX}/lib/python#{short_version}/site-packages"
end
end end
def python_short_version private
def short_version
@short_version ||= Language::Python.major_minor_version which_python @short_version ||= Language::Python.major_minor_version which_python
end end
@ -46,7 +47,7 @@ class PythonRequirement < Requirement
end end
def python_binary def python_binary
"python" "python2.7"
end end
# Deprecated # Deprecated
@ -59,6 +60,8 @@ class Python3Requirement < PythonRequirement
satisfy(build_env: false) { which_python } satisfy(build_env: false) { which_python }
private
def python_binary def python_binary
"python3" "python3"
end end