Skip to content

Commit 9bd97a2

Browse files
miss-islingtonkcdoddmerwokambv
authored
gh-90355: Add isolated flag if currently isolated (GH-92857) (GH-94568)
Co-authored-by: Carter Dodd <[email protected]> Co-authored-by: Éric <[email protected]> Co-authored-by: Łukasz Langa <[email protected]> (cherry picked from commit c8556bc)
1 parent 49aeda9 commit 9bd97a2

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Lib/ensurepip/__init__.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,18 @@ def _run_pip(args, additional_paths=None):
8989
sys.argv[1:] = {args}
9090
runpy.run_module("pip", run_name="__main__", alter_sys=True)
9191
"""
92-
return subprocess.run([sys.executable, '-W', 'ignore::DeprecationWarning',
93-
"-c", code], check=True).returncode
92+
93+
cmd = [
94+
sys.executable,
95+
'-W',
96+
'ignore::DeprecationWarning',
97+
'-c',
98+
code,
99+
]
100+
if sys.flags.isolated:
101+
# run code in isolated mode if currently running isolated
102+
cmd.insert(1, '-I')
103+
return subprocess.run(cmd, check=True).returncode
94104

95105

96106
def version():
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix :mod:`ensurepip` environment isolation for subprocess running ``pip``.

0 commit comments

Comments
 (0)