mirror of
https://github.com/python/cpython.git
synced 2026-01-08 08:22:41 +00:00
[3.12] Workaround 3.12.5 bundled pip 24.2 issue on macOS 10.9 to 10.12. (#122774)
Workaround bundled pip 24.2 failures on macOS 10.9 to 10.12 installers. See https://github.com/pypa/pip/issues/12901 for more information.
This commit is contained in:
parent
f4aad5a6d2
commit
76a0dfa42e
3 changed files with 100 additions and 20 deletions
|
|
@ -10,22 +10,52 @@
|
|||
|
||||
import os
|
||||
import os.path
|
||||
import platform
|
||||
import ssl
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
|
||||
| stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP
|
||||
| stat.S_IROTH | stat.S_IXOTH )
|
||||
STAT_0o775 = (
|
||||
stat.S_IRUSR
|
||||
| stat.S_IWUSR
|
||||
| stat.S_IXUSR
|
||||
| stat.S_IRGRP
|
||||
| stat.S_IWGRP
|
||||
| stat.S_IXGRP
|
||||
| stat.S_IROTH
|
||||
| stat.S_IXOTH
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
openssl_dir, openssl_cafile = os.path.split(
|
||||
ssl.get_default_verify_paths().openssl_cafile)
|
||||
pip_call = [sys.executable, "-E", "-s", "-m", "pip"]
|
||||
macos_release = tuple([int(n) for n in platform.mac_ver()[0].split(".")[0:2]])
|
||||
old_macos = macos_release < (10, 13)
|
||||
if old_macos:
|
||||
pip_version_string = subprocess.check_output(pip_call + ["-V"]).decode().strip()
|
||||
# Silence warning to user to upgrade pip
|
||||
pip_call.append("--disable-pip-version-check")
|
||||
pip_version = tuple(
|
||||
[int(n) for n in pip_version_string.split()[1].split(".")[0:2]]
|
||||
)
|
||||
if pip_version >= (24, 2):
|
||||
print(
|
||||
f" -- WARNING: this version of pip may not work on this older version of macOS.\n"
|
||||
f" found {pip_version_string}\n"
|
||||
f" (See https://github.com/pypa/pip/issues/12901 for more information.)\n"
|
||||
f" Attempting to revert to an older version of pip.\n"
|
||||
f" -- pip install --use-deprecated=legacy-certs pip==24.1.2\n"
|
||||
)
|
||||
subprocess.check_call(
|
||||
pip_call + ["install", "--use-deprecated=legacy-certs", "pip==24.1.2"]
|
||||
)
|
||||
|
||||
openssl_dir, openssl_cafile = os.path.split(
|
||||
ssl.get_default_verify_paths().openssl_cafile
|
||||
)
|
||||
print(" -- pip install --upgrade certifi")
|
||||
subprocess.check_call([sys.executable,
|
||||
"-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"])
|
||||
subprocess.check_call(pip_call + ["install", "--upgrade", "certifi"])
|
||||
|
||||
import certifi
|
||||
|
||||
|
|
@ -42,7 +72,16 @@ def main():
|
|||
print(" -- setting permissions")
|
||||
os.chmod(openssl_cafile, STAT_0o775)
|
||||
print(" -- update complete")
|
||||
if old_macos:
|
||||
print(
|
||||
f" -- WARNING: Future releases of this Python installer may not support this older macOS version.\n"
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except subprocess.SubprocessError:
|
||||
print(" -- WARNING: Install Certificates failed")
|
||||
sys.exit(1)
|
||||
EOF
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue