8000 [3.9] gh-90355: Add isolated flag if currently isolated (GH-92857) by ambv · Pull Request #94570 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.9] gh-90355: Add isolated flag if currently isolated (GH-92857) #94570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[3.9] 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>
(cherry picked from commit c8556bc)

Co-authored-by: Carter Dodd <carter.dodd@gmail.com>
  • Loading branch information
kcdodd authored and ambv committed Jul 5, 2022
commit 86abe53866b348638076f25f3a4b20b4eb6c8e65
7 changes: 6 additions & 1 deletion Lib/ensurepip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ def _run_pip(args, additional_paths=None):
sys.argv[1:] = {args}
runpy.run_module("pip", run_name="__main__", alter_sys=True)
"""
return subprocess.run([sys.executable, "-c", code], check=True).returncode

cmd = [sys.executable, '-c', code]
if sys.flags.isolated:
# run code in isolated mode if currently running isolated
cmd.insert(1, '-I')
return subprocess.run(cmd, check=True).returncode


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