diff options
| author | MinRK | 2013-11-21 21:33:58 -0800 |
|---|---|---|
| committer | Adam Vandenberg | 2013-11-25 20:48:41 -0800 |
| commit | 34304bfef40d63a67f2bfc46c76228becf6a524e (patch) | |
| tree | 7e3fbb88794fa076ef388b2896f9745d5a6ca352 /Library/Homebrew/requirements/python_dependency.rb | |
| parent | 512373eea0fd467acd391ee45b5fa611ed1efbdc (diff) | |
| download | homebrew-34304bfef40d63a67f2bfc46c76228becf6a524e.tar.bz2 | |
safer check for sys.executable in sitecustomize.py
make sure it doesn't actually point to something else
since sitecustomize.py is put in a location found by pypy,
it breaks pypy by setting sys.executable to a path that is definitely wrong,
and may not even exist.
Closes #24581.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
Diffstat (limited to 'Library/Homebrew/requirements/python_dependency.rb')
| -rw-r--r-- | Library/Homebrew/requirements/python_dependency.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Library/Homebrew/requirements/python_dependency.rb b/Library/Homebrew/requirements/python_dependency.rb index 831b0ddc9..4ce9cd96f 100644 --- a/Library/Homebrew/requirements/python_dependency.rb +++ b/Library/Homebrew/requirements/python_dependency.rb @@ -296,10 +296,10 @@ class PythonDependency < Requirement # This file is created by Homebrew and is executed on each python startup. # Don't print from here, or else python command line scripts may fail! # <https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python> + import os import sys if sys.version_info[0] != #{version.major}: - import os # This can only happen if the user has set the PYTHONPATH for 3.x and run Python 2.x or vice versa. # Every Python looks at the PYTHONPATH variable and we can't fix it here in sitecustomize.py, # because the PYTHONPATH is evaluated after the sitecustomize.py. Many modules (e.g. PyQt4) are @@ -310,7 +310,8 @@ class PythonDependency < Requirement ' You should `unset PYTHONPATH` to fix this.') else: # Only do this for a brewed python: - if sys.executable.startswith('#{HOMEBREW_PREFIX}'): + opt_executable = '#{HOMEBREW_PREFIX}/opt/#{python}/bin/#{xy}' + if os.path.realpath(sys.executable) == os.path.realpath(opt_executable): # Remove /System site-packages, and the Cellar site-packages # which we moved to lib/pythonX.Y/site-packages. Further, remove # HOMEBREW_PREFIX/lib/python because we later addsitedir(...). @@ -331,7 +332,7 @@ class PythonDependency < Requirement pass # remember: don't print here. Better to fail silently. # Set the sys.executable to use the opt_prefix - sys.executable = '#{HOMEBREW_PREFIX}/opt/#{python}/bin/#{xy}' + sys.executable = opt_executable # Tell about homebrew's site-packages location. # This is needed for Python to parse *.pth. |
