54 lines
2.1 KiB
Diff
54 lines
2.1 KiB
Diff
--- a/certifi/core.py
|
|
+++ b/certifi/core.py
|
|
@@ -10,36 +10,15 @@ import sys
|
|
if sys.version_info >= (3, 11):
|
|
|
|
from importlib.resources import as_file, files
|
|
+ from pathlib import Path
|
|
|
|
- _CACERT_CTX = None
|
|
- _CACERT_PATH = None
|
|
+ _CACERT_PATH = '/etc/ssl/certs.pem'
|
|
|
|
def where() -> str:
|
|
- # This is slightly terrible, but we want to delay extracting the file
|
|
- # in cases where we're inside of a zipimport situation until someone
|
|
- # actually calls where(), but we don't want to re-extract the file
|
|
- # on every call of where(), so we'll do it once then store it in a
|
|
- # global variable.
|
|
- global _CACERT_CTX
|
|
- global _CACERT_PATH
|
|
- if _CACERT_PATH is None:
|
|
- # This is slightly janky, the importlib.resources API wants you to
|
|
- # manage the cleanup of this file, so it doesn't actually return a
|
|
- # path, it returns a context manager that will give you the path
|
|
- # when you enter it and will do any cleanup when you leave it. In
|
|
- # the common case of not needing a temporary file, it will just
|
|
- # return the file system location and the __exit__() is a no-op.
|
|
- #
|
|
- # 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 = as_file(files("certifi").joinpath("cacert.pem"))
|
|
- _CACERT_PATH = str(_CACERT_CTX.__enter__())
|
|
-
|
|
return _CACERT_PATH
|
|
|
|
def contents() -> str:
|
|
- return files("certifi").joinpath("cacert.pem").read_text(encoding="ascii")
|
|
+ return Path(_CACERT_PATH).read_text(encoding="ascii")
|
|
|
|
elif sys.version_info >= (3, 7):
|
|
|
|
--- a/setup.py
|
|
+++ b/setup.py
|
|
@@ -41,7 +41,7 @@ setup(
|
|
'certifi',
|
|
],
|
|
package_dir={'certifi': 'certifi'},
|
|
- package_data={'certifi': ['*.pem', 'py.typed']},
|
|
+ package_data={'certifi': ['py.typed']},
|
|
# data_files=[('certifi', ['certifi/cacert.pem'])],
|
|
include_package_data=True,
|
|
zip_safe=False,
|