@@ -54,47 +54,6 @@ def _create_standalone_pip() -> Iterator[str]:
54
54
yield os .path .join (pip_zip , "pip" )
55
55
56
56
57
- def _install_requirements (
58
- standalone_pip : str ,
59
- finder : "PackageFinder" ,
60
- requirements : Iterable [str ],
61
- prefix : _Prefix ,
62
- message : str ,
63
- ) -> None :
64
- args = [
65
- sys .executable , standalone_pip , 'install' ,
66
- '--ignore-installed' , '--no-user' , '--prefix' , prefix .path ,
67
- '--cert' , where (), '--no-warn-script-location' ,
68
- ] # type: List[str]
69
- if logger .getEffectiveLevel () <= logging .DEBUG :
70
- args .append ('-v' )
71
- for format_control in ('no_binary' , 'only_binary' ):
72
- formats = getattr (finder .format_control , format_control )
73
- args += [
74
- '--' + format_control .replace ('_' , '-' ),
75
- ',' .join (sorted (formats or {':none:' }))
76
- ]
77
- index_urls = finder .index_urls
78
- if index_urls :
79
- args .extend (['-i' , index_urls [0 ]])
80
- for extra_index in index_urls [1 :]:
81
- args .extend (['--extra-index-url' , extra_index ])
82
- else :
83
- args .append ('--no-index' )
84
- for link in finder .find_links :
85
- args .extend (['--find-links' , link ])
86
- for host in finder .trusted_hosts :
87
- args .extend (['--trusted-host' , host ])
88
- if finder .allow_all_prereleases :
89
- args .append ('--pre' )
90
- if finder .prefer_binary :
91
- args .append ('--prefer-binary' )
92
- args .append ('--' )
93
- args .extend (requirements )
94
- with open_spinner (message ) as spinner :
95
- call_subprocess (args , spinner = spinner )
96
-
97
-
98
57
class BuildEnvironment :
99
58
"""Creates and manages an isolated environment to install build deps
100
59
"""
@@ -219,14 +178,55 @@ def install_requirements(
219
178
if not requirements :
220
179
return
221
180
with _create_standalone_pip () as standalone_pip :
222
- _install_requirements (
181
+ self . _install_requirements (
223
182
standalone_pip ,
224
183
finder ,
225
184
requirements ,
226
185
prefix ,
227
186
message ,
228
187
)
229
188
189
+ @staticmethod
190
+ def _install_requirements (
191
+ standalone_pip : str ,
192
+ finder : "PackageFinder" ,
193
+ requirements : Iterable [str ],
194
+ prefix : _Prefix ,
195
+ message : str ,
196
+ ) -> None :
197
+ args = [
198
+ sys .executable , standalone_pip , 'install' ,
199
+ '--ignore-installed' , '--no-user' , '--prefix' , prefix .path ,
200
+ '--no-warn-script-location' , '--cert' , where (),
201
+ ] # type: List[str]
202
+ if logger .getEffectiveLevel () <= logging .DEBUG :
203
+ args .append ('-v' )
204
+ for format_control in ('no_binary' , 'only_binary' ):
205
+ formats = getattr (finder .format_control , format_control )
206
+ args .extend (('--' + format_control .replace ('_' , '-' ),
207
+ ',' .join (sorted (formats or {':none:' }))))
208
+
209
+ index_urls = finder .index_urls
210
+ if index_urls :
211
+ args .extend (['-i' , index_urls [0 ]])
212
+ for extra_index in index_urls [1 :]:
213
+ args .extend (['--extra-index-url' , extra_index ])
214
+ else :
215
+ args .append ('--no-index' )
216
+ for link in finder .find_links :
217
+ args .extend (['--find-links' , link ])
218
+
219
+ for host in finder .trusted_hosts :
220
+ args .extend (['--trusted-host' , host ])
221
+ if finder .allow_all_prereleases :
222
+ args .append ('--pre' )
223
+ if finder .prefer_binary :
224
+ args .append ('--prefer-binary' )
225
+ args .append ('--' )
226
+ args .extend (requirements )
227
+ with open_spinner (message ) as spinner :
228
+ call_subprocess (args , spinner = spinner )
229
+
230
230
231
231
class NoOpBuildEnvironment (BuildEnvironment ):
232
232
"""A no-op drop-in replacement for BuildEnvironment
0 commit comments