python@3.8: use f-string in sitecustomize.py
parent
53ba8f5275
commit
a7a60f4477
|
@ -355,9 +355,10 @@ class PythonAT38 < Formula
|
|||
# because the PYTHONPATH is evaluated after the sitecustomize.py. Many modules (e.g. PyQt4) are
|
||||
# built only for a specific version of Python and will fail with cryptic error messages.
|
||||
# In the end this means: Don't set the PYTHONPATH permanently if you use different Python versions.
|
||||
exit('Your PYTHONPATH points to a site-packages dir for Python 3.x but you are running Python ' +
|
||||
str(sys.version_info[0]) + '.x!\\n PYTHONPATH is currently: "' + str(os.environ['PYTHONPATH']) + '"\\n' +
|
||||
' You should `unset PYTHONPATH` to fix this.')
|
||||
exit(f'Your PYTHONPATH points to a site-packages dir for Python 3.x '
|
||||
f'but you are running Python {sys.version_info[0]}.x!\\n'
|
||||
f' PYTHONPATH is currently: "{os.environ["PYTHONPATH"]}"\\n'
|
||||
f' You should `unset PYTHONPATH` to fix this.')
|
||||
# Only do this for a brewed python:
|
||||
if os.path.realpath(sys.executable).startswith('#{rack}'):
|
||||
# Shuffle /Library site-packages to the end of sys.path
|
||||
|
@ -369,7 +370,7 @@ class PythonAT38 < Formula
|
|||
# the Cellar site-packages is a symlink to the HOMEBREW_PREFIX
|
||||
# site_packages; prefer the shorter paths
|
||||
long_prefix = re.compile(r'#{rack}/[0-9._abrc]+/Frameworks/Python.framework/Versions/#{version.major_minor}/lib/python#{version.major_minor}/site-packages')
|
||||
sys.path = [long_prefix.sub('#{HOMEBREW_PREFIX/"lib/python#{version.major_minor}/site-packages"}', p) for p in sys.path]
|
||||
sys.path = [long_prefix.sub('#{site_packages}', p) for p in sys.path]
|
||||
# Set the sys.executable to use the opt_prefix. Only do this if PYTHONEXECUTABLE is not
|
||||
# explicitly set and we are not in a virtualenv:
|
||||
if 'PYTHONEXECUTABLE' not in os.environ and sys.prefix == sys.base_prefix:
|
||||
|
|
Loading…
Reference in New Issue