@@ -41,28 +41,6 @@ def __init__(self, path):
41
41
self .lib_dirs = get_prefixed_libs (path )
42
42
43
43
44
- _CERTIFI_WHERE_PATCH = """
45
- from pip._vendor import certifi
46
- certifi.where = lambda: {pem!r}
47
- """
48
-
49
-
50
- def _format_init_py (source : pathlib .Path ) -> bytes :
51
- """Create a patched pip/__init__.py for the standalone pip.
52
-
53
- The default ``certifi.where()`` relies on the certificate bundle being a
54
- real physical file on-disk, so we monkey-patch it to return the one used
55
- by this process instead.
56
-
57
- Passing ``--cert`` to the standalone pip does not work, since ``requests``
58
- calls ``where()`` unconditionally on import.
59
- """
60
- with source .open ("rb" ) as f :
61
- content = f .read ()
62
- patch = _CERTIFI_WHERE_PATCH .format (pem = where ()).encode ("utf-8" )
63
- return patch + content
64
-
65
-
66
44
@contextlib .contextmanager
67
45
def _create_standalone_pip () -> Iterator [str ]:
68
46
"""Create a "standalone pip" zip file.
@@ -75,11 +53,7 @@ def _create_standalone_pip() -> Iterator[str]:
75
53
pip_zip = os .path .join (tmp_dir .path , "pip.zip" )
76
54
with zipfile .ZipFile (pip_zip , "w" ) as zf :
77
55
for child in source .rglob ("*" ):
78
- arcname = child .relative_to (source .parent ).as_posix ()
79
- if arcname == "pip/__init__.py" :
80
- zf .writestr (arcname , _format_init_py (child ))
81
- else :
82
- zf .write (child , arcname )
56
+ zf .write (child , child .relative_to (source .parent ).as_posix ())
83
57
yield os .path .join (pip_zip , "pip" )
84
58
85
59
@@ -253,8 +227,9 @@ def _install_requirements(
253
227
args .append ('--prefer-binary' )
254
228
args .append ('--' )
255
229
args .extend (requirements )
230
+ extra_environ = {"_PIP_STANDALONE_CERT" : where ()}
256
231
with open_spinner (message ) as spinner :
257
- call_subprocess (args , spinner = spinner )
232
+ call_subprocess (args , spinner = spinner , extra_environ = extra_environ )
258
233
259
234
260
235
class NoOpBuildEnvironment (BuildEnvironment ):
0 commit comments