Blame SOURCES/dummy-certifi.patch

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