diff options
| author | Mike McQuaid | 2017-12-14 09:21:26 +0000 |
|---|---|---|
| committer | Mike McQuaid | 2017-12-14 09:21:26 +0000 |
| commit | f4e647cbc6b3dbc3f128d09e0709b0a559eb9e84 (patch) | |
| tree | f236f35b738973dabebff6a9a36d7bf7332669b3 | |
| parent | 71ebfa76c53408a2fb40cbc95bb6f39be27da6b7 (diff) | |
| download | brew-f4e647cbc6b3dbc3f128d09e0709b0a559eb9e84.tar.bz2 | |
python_requirement: various tweaks/fixes.
- simplify the code by avoiding some unnecessary variables and rename
functions
- make more stuff private so implementation details don't leak
- make Python 2 binary `python2.7` to handle cases like those in
https://github.com/Homebrew/homebrew-core/issues/21500
- only set `PYTHONPATH` for system Python; Homebrew's Python doesn't
need it.
| -rw-r--r-- | Library/Homebrew/requirements/python_requirement.rb | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/Library/Homebrew/requirements/python_requirement.rb b/Library/Homebrew/requirements/python_requirement.rb index c162b072c..3215d0a6c 100644 --- a/Library/Homebrew/requirements/python_requirement.rb +++ b/Library/Homebrew/requirements/python_requirement.rb @@ -7,15 +7,12 @@ class PythonRequirement < Requirement satisfy build_env: false do python = which_python next unless python - version = python_short_version - next unless version + next unless short_version # 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 env do - short_version = python_short_version - if !system_python? && short_version == Version.create("2.7") ENV.prepend_path "PATH", which_python.dirname end @@ -24,10 +21,14 @@ class PythonRequirement < Requirement ENV.prepend_path "PATH", Formula["python"].opt_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 - def python_short_version + private + + def short_version @short_version ||= Language::Python.major_minor_version which_python end @@ -46,7 +47,7 @@ class PythonRequirement < Requirement end def python_binary - "python" + "python2.7" end # Deprecated @@ -59,6 +60,8 @@ class Python3Requirement < PythonRequirement satisfy(build_env: false) { which_python } + private + def python_binary "python3" end |
