From 28b4f2b9420b1a8b8133c5e6b950038c04b2aef5 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Thu, 26 May 2022 08:15:12 -0700 Subject: [PATCH] windows: use `python.exe -m pip` to invoke pip pip 22.1.1 broke the old `python.exe pip.wheel/pip install` invocation. See https://github.com/pypa/pip/issues/11146. --- cpython-windows/build.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/cpython-windows/build.py b/cpython-windows/build.py index 1330df59..9352f177 100644 --- a/cpython-windows/build.py +++ b/cpython-windows/build.py @@ -2235,31 +2235,42 @@ def build_cpython( os.environ, ) + # We install pip by using pip to install itself. This leverages a feature + # where Python can automatically recognize wheel/zip files on sys.path and + # import their contents. According to + # https://github.com/pypa/pip/issues/11146 running pip from a wheel is not + # supported. But it has historically worked and is simple. So do this until + # it stops working and we need to switch to running pip from the filesytem. + pip_env = dict(os.environ) + pip_env["PYTHONPATH"] = str(pip_wheel) + # Install pip and setuptools. exec_and_log( [ str(install_dir / "python.exe"), - str(pip_wheel / "pip"), + "-m", + "pip", "install", "--no-cache-dir", "--no-index", str(pip_wheel), ], td, - os.environ, + pip_env, ) exec_and_log( [ str(install_dir / "python.exe"), - str(pip_wheel / "pip"), + "-m", + "pip", "install", "--no-cache-dir", "--no-index", str(setuptools_wheel), ], td, - os.environ, + pip_env, ) # The executables in the Scripts/ directory don't work because they reference