python@3.9: use f-string in sitecustomize.py
parent
a7a60f4477
commit
ebeeec6465
|
@ -411,9 +411,10 @@ class PythonAT39 < Formula
|
||||||
# because the PYTHONPATH is evaluated after the sitecustomize.py. Many modules (e.g. PyQt4) are
|
# 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.
|
# 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.
|
# 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 #{version.major_minor} but you are running Python ' +
|
exit(f'Your PYTHONPATH points to a site-packages dir for Python #{version.major_minor} '
|
||||||
str(sys.version_info[0]) + '.' + str(sys.version_info[1]) + '!\\n PYTHONPATH is currently: "' + str(os.environ['PYTHONPATH']) + '"\\n' +
|
f'but you are running Python {sys.version_info[0]}.{sys.version_info[1]}!\\n'
|
||||||
' You should `unset PYTHONPATH` to fix this.')
|
f' PYTHONPATH is currently: "{os.environ["PYTHONPATH"]}"\\n'
|
||||||
|
f' You should `unset PYTHONPATH` to fix this.')
|
||||||
# Only do this for a brewed python:
|
# Only do this for a brewed python:
|
||||||
if os.path.realpath(sys.executable).startswith('#{rack}'):
|
if os.path.realpath(sys.executable).startswith('#{rack}'):
|
||||||
# Shuffle /Library site-packages to the end of sys.path
|
# Shuffle /Library site-packages to the end of sys.path
|
||||||
|
@ -425,7 +426,7 @@ class PythonAT39 < Formula
|
||||||
# the Cellar site-packages is a symlink to the HOMEBREW_PREFIX
|
# the Cellar site-packages is a symlink to the HOMEBREW_PREFIX
|
||||||
# site_packages; prefer the shorter paths
|
# 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')
|
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
|
# 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:
|
# explicitly set and we are not in a virtualenv:
|
||||||
if 'PYTHONEXECUTABLE' not in os.environ and sys.prefix == sys.base_prefix:
|
if 'PYTHONEXECUTABLE' not in os.environ and sys.prefix == sys.base_prefix:
|
||||||
|
|
Loading…
Reference in New Issue