-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace complex certifi patch with a more targetted requests patch
This should have the same final functionality, with a cleaner patch to requests instead of an exception-based complex patch to certifi.
- Loading branch information
Showing
4 changed files
with
38 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,19 @@ | ||
diff --git a/src/pip/_vendor/certifi/core.py b/src/pip/_vendor/certifi/core.py | ||
index 497d938..f34045b 100644 | ||
index 497d938d0..60ad982c6 100644 | ||
--- a/src/pip/_vendor/certifi/core.py | ||
+++ b/src/pip/_vendor/certifi/core.py | ||
@@ -8,7 +8,21 @@ import os | ||
import types | ||
from typing import Union | ||
|
||
+ | ||
+class _PipPatchedCertificate(Exception): | ||
+ pass | ||
+ | ||
+ | ||
try: | ||
+ # Return a certificate file on disk for a standalone pip zipapp running in | ||
+ # an isolated build environment to use. Passing --cert to the standalone | ||
+ # pip does not work since requests calls where() unconditionally on import. | ||
+ _PIP_STANDALONE_CERT = os.environ.get("_PIP_STANDALONE_CERT") | ||
+ if _PIP_STANDALONE_CERT: | ||
+ def where(): | ||
+ return _PIP_STANDALONE_CERT | ||
+ raise _PipPatchedCertificate() | ||
+ | ||
from importlib.resources import path as get_path, read_text | ||
|
||
_CACERT_CTX = None | ||
@@ -33,11 +47,13 @@ try: | ||
@@ -33,7 +33,7 @@ def where() -> str: | ||
# We also have to hold onto the actual context manager, because | ||
# it will do the cleanup whenever it gets garbage collected, so | ||
# we will also store that at the global level as well. | ||
- _CACERT_CTX = get_path("certifi", "cacert.pem") | ||
+ _CACERT_CTX = get_path("pip._vendor.certifi", "cacert.pem") | ||
_CACERT_PATH = str(_CACERT_CTX.__enter__()) | ||
|
||
return _CACERT_PATH | ||
+except _PipPatchedCertificate: | ||
+ pass | ||
|
||
except ImportError: | ||
Package = Union[types.ModuleType, str] | ||
@@ -65,4 +65,4 @@ def where() -> str: | ||
|
||
|
||
def contents() -> str: | ||
- return read_text("certifi", "cacert.pem", encoding="ascii") | ||
+ return read_text("pip._vendor.certifi", "cacert.pem", encoding="ascii") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters