aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/requirements/python_dependency.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/requirements/python_dependency.rb')
-rw-r--r--Library/Homebrew/requirements/python_dependency.rb7
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.