8
8
from importlib import resources
9
9
10
10
11
-
12
11
__all__ = ["version" , "bootstrap" ]
13
12
_PACKAGE_NAMES = ('setuptools' , 'pip' )
14
- _SETUPTOOLS_VERSION = "58.1 .0"
15
- _PIP_VERSION = "22.0.4 "
13
+ _SETUPTOOLS_VERSION = "65.5 .0"
14
+ _PIP_VERSION = "22.3.1 "
16
15
_PROJECTS = [
17
16
("setuptools" , _SETUPTOOLS_VERSION , "py3" ),
18
17
("pip" , _PIP_VERSION , "py3" ),
@@ -79,8 +78,8 @@ def _get_packages():
79
78
80
79
81
80
def _run_pip (args , additional_paths = None ):
82
- # Run the bootstraping in a subprocess to avoid leaking any state that happens
83
- # after pip has executed. Particulary , this avoids the case when pip holds onto
81
+ # Run the bootstrapping in a subprocess to avoid leaking any state that happens
82
+ # after pip has executed. Particularly , this avoids the case when pip holds onto
84
83
# the files in *additional_paths*, preventing us to remove them at the end of the
85
84
# invocation.
86
85
code = f"""
@@ -90,8 +89,18 @@ def _run_pip(args, additional_paths=None):
90
89
sys.argv[1:] = { args }
91
90
runpy.run_module("pip", run_name="__main__", alter_sys=True)
92
91
"""
93
- return subprocess .run ([sys .executable , '-W' , 'ignore::DeprecationWarning' ,
94
- "-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
95
104
96
105
97
106
def version ():
@@ -164,9 +173,9 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
164
173
for name , package in _get_packages ().items ():
165
174
if package .wheel_name :
166
175
# Use bundled wheel package
167
- from ensurepip import _bundled
168
176
wheel_name = package .wheel_name
169
- whl = resources .read_binary (_bundled , wheel_name )
177
+ wheel_path = resources .files ("ensurepip" ) / "_bundled" / wheel_name
178
+ whl = wheel_path .read_bytes ()
170
179
else :
171
180
# Use the wheel package directory
172
181
with open (package .wheel_path , "rb" ) as fp :
0 commit comments