From bf2fbb48e93def7cacc3ea860072ba2542084008 Mon Sep 17 00:00:00 2001 From: Carter Dodd Date: Wed, 29 Dec 2021 20:56:56 -0600 Subject: [PATCH 1/4] bpo-46197: Add isolated flag if currently isolated --- Lib/ensurepip/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py index 0a5730c00c3596..b42f1ece8dfd81 100644 --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -90,8 +90,16 @@ 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, '-W', 'ignore::DeprecationWarning', - "-c", code], check=True).returncode + + cmd = [ + sys.executable, + # run pip interpreter in isolated mode if current interpreter was isolated + *( [ '-I', ] if sys.flags.isolated else [] ), + '-W', 'ignore::DeprecationWarning', + '-c', + code ] + + return subprocess.run( cmd, check = True ).returncode def version(): From b3a2047ca05da332e77bb286e2c0d8b52d7be4de Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:07:07 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NEWS.d/next/Library/2022-01-03-15-07-06.bpo-46197.Z0djv6.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2022-01-03-15-07-06.bpo-46197.Z0djv6.rst diff --git a/Misc/NEWS.d/next/Library/2022-01-03-15-07-06.bpo-46197.Z0djv6.rst b/Misc/NEWS.d/next/Library/2022-01-03-15-07-06.bpo-46197.Z0djv6.rst new file mode 100644 index 00000000000000..3a4f5e0edf7bf6 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-01-03-15-07-06.bpo-46197.Z0djv6.rst @@ -0,0 +1 @@ +Fix :mod:`ensurepip` environment isolation for sub-process. \ No newline at end of file From b33305db688f82b7f311c7fd5729787b99d29291 Mon Sep 17 00:00:00 2001 From: Carter Dodd Date: Mon, 3 Jan 2022 15:50:01 -0600 Subject: [PATCH 3/4] Update Lib/ensurepip/__init__.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric --- Lib/ensurepip/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py index b42f1ece8dfd81..e92a778d25628f 100644 --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -93,7 +93,7 @@ def _run_pip(args, additional_paths=None): cmd = [ sys.executable, - # run pip interpreter in isolated mode if current interpreter was isolated + # run code in isolated mode if currently running isolated *( [ '-I', ] if sys.flags.isolated else [] ), '-W', 'ignore::DeprecationWarning', '-c', From 5656a447b6328126d271a1947d7d33be9dbd872d Mon Sep 17 00:00:00 2001 From: Carter Dodd Date: Mon, 16 May 2022 08:50:58 -0500 Subject: [PATCH 4/4] Update Lib/ensurepip/__init__.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric --- Lib/ensurepip/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py index e92a778d25628f..d9c76520f6c6d9 100644 --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -94,7 +94,7 @@ def _run_pip(args, additional_paths=None): cmd = [ sys.executable, # run code in isolated mode if currently running isolated - *( [ '-I', ] if sys.flags.isolated else [] ), + *([ '-I'] if sys.flags.isolated else []), '-W', 'ignore::DeprecationWarning', '-c', code ]