Skip to content

Commit bba1226

Browse files
committed
Handle zipapp inception
1 parent 9cab77e commit bba1226

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/pip/_internal/build_env.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,19 @@ def __init__(self, path):
4545
def _create_standalone_pip() -> Iterator[str]:
4646
"""Create a "standalone pip" zip file.
4747
48-
The zip file contains a (modified) copy of the pip currently running.
48+
The zip file's content is identical to the currently-running pip.
4949
It will be used to install requirements into the build environment.
5050
"""
5151
source = pathlib.Path(pip_location).resolve().parent
52+
53+
# Return the current instance if it is already a zip file. This can happen
54+
# if a PEP 517 requirement is an sdist itself.
55+
if not source.is_dir() and source.parent.name == "__env_pip__.zip":
56+
yield str(source)
57+
return
58+
5259
with TempDirectory(kind="standalone-pip") as tmp_dir:
53-
pip_zip = os.path.join(tmp_dir.path, "pip.zip")
60+
pip_zip = os.path.join(tmp_dir.path, "__env_pip__.zip")
5461
with zipfile.ZipFile(pip_zip, "w") as zf:
5562
for child in source.rglob("*"):
5663
zf.write(child, child.relative_to(source.parent).as_posix())

0 commit comments

Comments
 (0)