Blame SOURCES/dummy-certifi.patch

49df85
From 09c983fdeabe3fa0b90b73f32ddf84a61e498e09 Mon Sep 17 00:00:00 2001
49df85
From: Karolina Surma <ksurma@redhat.com>
49df85
Date: Tue, 15 Nov 2022 09:22:46 +0100
49df85
Subject: [PATCH] Dummy certifi patch
49df85
49df85
---
49df85
 src/pip/_vendor/certifi/core.py | 105 ++------------------------------
49df85
 1 file changed, 6 insertions(+), 99 deletions(-)
49df85
49df85
diff --git a/src/pip/_vendor/certifi/core.py b/src/pip/_vendor/certifi/core.py
49df85
index c3e5466..eb297f7 100644
49df85
--- a/src/pip/_vendor/certifi/core.py
49df85
+++ b/src/pip/_vendor/certifi/core.py
49df85
@@ -4,105 +4,12 @@ certifi.py
49df85
 
49df85
 This module returns the installation location of cacert.pem or its contents.
49df85
 """
49df85
-import sys
49df85
 
49df85
+# The RPM-packaged certifi always uses the system certificates
49df85
+def where() -> str:
49df85
+    return '/etc/pki/tls/certs/ca-bundle.crt'
49df85
 
49df85
-if sys.version_info >= (3, 11):
49df85
+def contents() -> str:
49df85
+    with open(where(), encoding='utf=8') as data:
49df85
+        return data.read()
49df85
 
49df85
-    from importlib.resources import as_file, files
49df85
-
49df85
-    _CACERT_CTX = None
49df85
-    _CACERT_PATH = None
49df85
-
49df85
-    def where() -> str:
49df85
-        # This is slightly terrible, but we want to delay extracting the file
49df85
-        # in cases where we're inside of a zipimport situation until someone
49df85
-        # actually calls where(), but we don't want to re-extract the file
49df85
-        # on every call of where(), so we'll do it once then store it in a
49df85
-        # global variable.
49df85
-        global _CACERT_CTX
49df85
-        global _CACERT_PATH
49df85
-        if _CACERT_PATH is None:
49df85
-            # This is slightly janky, the importlib.resources API wants you to
49df85
-            # manage the cleanup of this file, so it doesn't actually return a
49df85
-            # path, it returns a context manager that will give you the path
49df85
-            # when you enter it and will do any cleanup when you leave it. In
49df85
-            # the common case of not needing a temporary file, it will just
49df85
-            # return the file system location and the __exit__() is a no-op.
49df85
-            #
49df85
-            # We also have to hold onto the actual context manager, because
49df85
-            # it will do the cleanup whenever it gets garbage collected, so
49df85
-            # we will also store that at the global level as well.
49df85
-            _CACERT_CTX = as_file(files("pip._vendor.certifi").joinpath("cacert.pem"))
49df85
-            _CACERT_PATH = str(_CACERT_CTX.__enter__())
49df85
-
49df85
-        return _CACERT_PATH
49df85
-
49df85
-    def contents() -> str:
49df85
-        return files("pip._vendor.certifi").joinpath("cacert.pem").read_text(encoding="ascii")
49df85
-
49df85
-elif sys.version_info >= (3, 7):
49df85
-
49df85
-    from importlib.resources import path as get_path, read_text
49df85
-
49df85
-    _CACERT_CTX = None
49df85
-    _CACERT_PATH = None
49df85
-
49df85
-    def where() -> str:
49df85
-        # This is slightly terrible, but we want to delay extracting the
49df85
-        # file in cases where we're inside of a zipimport situation until
49df85
-        # someone actually calls where(), but we don't want to re-extract
49df85
-        # the file on every call of where(), so we'll do it once then store
49df85
-        # it in a global variable.
49df85
-        global _CACERT_CTX
49df85
-        global _CACERT_PATH
49df85
-        if _CACERT_PATH is None:
49df85
-            # This is slightly janky, the importlib.resources API wants you
49df85
-            # to manage the cleanup of this file, so it doesn't actually
49df85
-            # return a path, it returns a context manager that will give
49df85
-            # you the path when you enter it and will do any cleanup when
49df85
-            # you leave it. In the common case of not needing a temporary
49df85
-            # file, it will just return the file system location and the
49df85
-            # __exit__() is a no-op.
49df85
-            #
49df85
-            # We also have to hold onto the actual context manager, because
49df85
-            # it will do the cleanup whenever it gets garbage collected, so
49df85
-            # we will also store that at the global level as well.
49df85
-            _CACERT_CTX = get_path("pip._vendor.certifi", "cacert.pem")
49df85
-            _CACERT_PATH = str(_CACERT_CTX.__enter__())
49df85
-
49df85
-        return _CACERT_PATH
49df85
-
49df85
-    def contents() -> str:
49df85
-        return read_text("pip._vendor.certifi", "cacert.pem", encoding="ascii")
49df85
-
49df85
-else:
49df85
-    import os
49df85
-    import types
49df85
-    from typing import Union
49df85
-
49df85
-    Package = Union[types.ModuleType, str]
49df85
-    Resource = Union[str, "os.PathLike"]
49df85
-
49df85
-    # This fallback will work for Python versions prior to 3.7 that lack the
49df85
-    # importlib.resources module but relies on the existing `where` function
49df85
-    # so won't address issues with environments like PyOxidizer that don't set
49df85
-    # __file__ on modules.
49df85
-    def read_text(
49df85
-        package: Package,
49df85
-        resource: Resource,
49df85
-        encoding: str = 'utf-8',
49df85
-        errors: str = 'strict'
49df85
-    ) -> str:
49df85
-        with open(where(), encoding=encoding) as data:
49df85
-            return data.read()
49df85
-
49df85
-    # If we don't have importlib.resources, then we will just do the old logic
49df85
-    # of assuming we're on the filesystem and munge the path directly.
49df85
-    def where() -> str:
49df85
-        f = os.path.dirname(__file__)
49df85
-
49df85
-        return os.path.join(f, "cacert.pem")
49df85
-
49df85
-    def contents() -> str:
49df85
-        return read_text("pip._vendor.certifi", "cacert.pem", encoding="ascii")
49df85
-- 
49df85
2.37.3
49df85