Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f78733b

Browse files
ambvkcdoddmerwok
authored
[3.8] gh-90355: Add isolated flag if currently isolated (GH-92857) (GH-94571)
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 bd0f2a1 commit f78733b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Lib/ensurepip/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ def _run_pip(args, additional_paths=None):
2929
sys.argv[1:] = {args}
3030
runpy.run_module("pip", run_name="__main__", alter_sys=True)
3131
"""
32-
return subprocess.run([sys.executable, "-c", code], check=True).returncode
32+
33+
cmd = [sys.executable, '-c', code]
34+
if sys.flags.isolated:
35+
# run code in isolated mode if currently running isolated
36+
cmd.insert(1, '-I')
37+
return subprocess.run(cmd, check=True).returncode
3338

3439

3540
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)