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

Skip to content

Commit c8556bc

Browse files
kcdoddmerwokambv
authored
gh-90355: Add isolated flag if currently isolated (GH-92857)
Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
1 parent 0675975 commit c8556bc

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
@@ -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():
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