Skip to content

Commit 28b4f2b

Browse files
committed
windows: use python.exe -m pip to invoke pip
pip 22.1.1 broke the old `python.exe pip.wheel/pip install` invocation. See pypa/pip#11146.
1 parent 7b9e96a commit 28b4f2b

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

cpython-windows/build.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,31 +2235,42 @@ def build_cpython(
22352235
os.environ,
22362236
)
22372237

2238+
# We install pip by using pip to install itself. This leverages a feature
2239+
# where Python can automatically recognize wheel/zip files on sys.path and
2240+
# import their contents. According to
2241+
# https://github.com/pypa/pip/issues/11146 running pip from a wheel is not
2242+
# supported. But it has historically worked and is simple. So do this until
2243+
# it stops working and we need to switch to running pip from the filesytem.
2244+
pip_env = dict(os.environ)
2245+
pip_env["PYTHONPATH"] = str(pip_wheel)
2246+
22382247
# Install pip and setuptools.
22392248
exec_and_log(
22402249
[
22412250
str(install_dir / "python.exe"),
2242-
str(pip_wheel / "pip"),
2251+
"-m",
2252+
"pip",
22432253
"install",
22442254
"--no-cache-dir",
22452255
"--no-index",
22462256
str(pip_wheel),
22472257
],
22482258
td,
2249-
os.environ,
2259+
pip_env,
22502260
)
22512261

22522262
exec_and_log(
22532263
[
22542264
str(install_dir / "python.exe"),
2255-
str(pip_wheel / "pip"),
2265+
"-m",
2266+
"pip",
22562267
"install",
22572268
"--no-cache-dir",
22582269
"--no-index",
22592270
str(setuptools_wheel),
22602271
],
22612272
td,
2262-
os.environ,
2273+
pip_env,
22632274
)
22642275

22652276
# The executables in the Scripts/ directory don't work because they reference

0 commit comments

Comments
 (0)