8000 gh-90355: Add isolated flag if currently isolated (GH-92857) (GH-94569) · python/cpython@922075c · GitHub
[go: up one dir, main page]

Skip to content

Commit 922075c

Browse files
miss-islingtonkcdoddmerwokambv
authored
gh-90355: Add isolated flag if currently isolated (GH-92857) (GH-94569)
Co-authored-by: Carter Dodd <carter.dodd@gmail.com> Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit c8556bc)
1 parent 3287e45 commit 922075c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Lib/ensurepip/__init__.py

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

96106

97107
def version():
Lines changed: 1 addition & 0 deletions
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)
0