public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python3.13] epel9: When built with bundled pip.whl, patch bundled certifi within to use ca-certificates
@ 2026-11-19 11:12
0 siblings, 0 replies; only message in thread
From: @ 2026-11-19 11:12 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/python3.13
Branch : epel9
Commit : bf01a21d1c3d6e4375512cc6dfba23e078a913db
Author : Miro Hrončok <miro@hroncok.cz>
Date : 2026-10-30T14:49:34+01:00
Stats : +129/-0 in 3 file(s)
URL : https://src.fedoraproject.org/rpms/python3.13/c/bf01a21d1c3d6e4375512cc6dfba23e078a913db?branch=epel9
Log:
When built with bundled pip.whl, patch bundled certifi within to use ca-certificates
(cherry picked from python3.16 commit c873d21a83d107d0d2ae9a7be5fb302b92165ccf)
---
diff --git a/pip-dummy-certifi.patch b/pip-dummy-certifi.patch
new file mode 100644
index 0000000..ce34415
--- /dev/null
+++ b/pip-dummy-certifi.patch
@@ -0,0 +1,103 @@
+From 7b5fbac83944e3a0dd975ff17b69358791b68721 Mon Sep 17 00:00:00 2001
+From: Karolina Surma <ksurma@redhat.com>
+Date: Thu, 27 Jun 2024 10:38:53 +0200
+Subject: [PATCH] Dummy certifi patch
+
+---
+ src/pip/_vendor/certifi/core.py | 80 +++------------------------------
+ 1 file changed, 6 insertions(+), 74 deletions(-)
+
+diff --git a/src/pip/_vendor/certifi/core.py b/src/pip/_vendor/certifi/core.py
+index 2f2f7e0..bec6595 100644
+--- a/src/pip/_vendor/certifi/core.py
++++ b/src/pip/_vendor/certifi/core.py
+@@ -4,80 +4,12 @@ certifi.py
+
+ This module returns the installation location of cacert.pem or its contents.
+ """
+-import sys
+-import atexit
+
+-def exit_cacert_ctx() -> None:
+- _CACERT_CTX.__exit__(None, None, None) # type: ignore[union-attr]
++# The RPM-packaged certifi always uses the system certificates
++def where() -> str:
++ return '/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem'
+
+
+-if sys.version_info >= (3, 11):
+-
+- from importlib.resources import as_file, files
+-
+- _CACERT_CTX = None
+- _CACERT_PATH = None
+-
+- 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("pip._vendor.certifi").joinpath("cacert.pem"))
+- _CACERT_PATH = str(_CACERT_CTX.__enter__())
+- atexit.register(exit_cacert_ctx)
+-
+- return _CACERT_PATH
+-
+- def contents() -> str:
+- return files("pip._vendor.certifi").joinpath("cacert.pem").read_text(encoding="ascii")
+-
+-else:
+-
+- from importlib.resources import path as get_path, read_text
+-
+- _CACERT_CTX = None
+- _CACERT_PATH = None
+-
+- 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 = get_path("pip._vendor.certifi", "cacert.pem")
+- _CACERT_PATH = str(_CACERT_CTX.__enter__())
+- atexit.register(exit_cacert_ctx)
+-
+- return _CACERT_PATH
+-
+- def contents() -> str:
+- return read_text("pip._vendor.certifi", "cacert.pem", encoding="ascii")
++def contents() -> str:
++ with open(where(), encoding='utf=8') as data:
++ return data.read()
+--
+2.50.1
+
diff --git a/plan.fmf b/plan.fmf
index 9c9afb8..41105ea 100644
--- a/plan.fmf
+++ b/plan.fmf
@@ -43,6 +43,9 @@ discover:
- name: marshalparser
path: /marshalparser
test: "VERSION=${pybasever} SAMPLE=10 ./test_marshalparser_compatibility.sh"
+ - name: certifi
+ path: /certifi
+ test: "VERSION=${pybasever} ./certifi.sh"
- name: required_symbols
path: /required-symbols
test: "VERSION=${pybasever} ./check.sh"
diff --git a/python3.13.spec b/python3.13.spec
index 92563a9..d8dfbd1 100644
--- a/python3.13.spec
+++ b/python3.13.spec
@@ -314,6 +314,7 @@ BuildRequires: libappstream-glib
BuildRequires: %{python_wheel_pkg_prefix}-pip-wheel >= 23.1.2
%if %{with tests}
BuildRequires: %{python_wheel_pkg_prefix}-setuptools-wheel >= 71
+BuildRequires: ca-certificates
%endif
%endif
@@ -350,6 +351,16 @@ Source10: idle3.desktop
# AppData file for idle3
Source11: idle3.appdata.xml
+# Patches for bundled wheels (declared as Sources, applied manually in %%prep):
+#
+# Use the system level root certificate instead of the one bundled in certifi
+# in the pip wheel bundled in ensurepip.
+# https://bugzilla.redhat.com/1655253
+# The same patch is a part of the RPM-packaged python-pip and python-certifi.
+Source41: pip-dummy-certifi.patch
+
+# Patches for Python
+#
# (Patches taken from github.com/fedora-python/cpython)
# 00251 # 5ac6e7781923cbb3e4606e3bca381a1167d322e5
@@ -567,6 +578,7 @@ License: %{libs_license}
%else
Provides: bundled(python3dist(pip)) = %{pip_version}
%pip_bundled_provides
+Requires: ca-certificates
# License combined from Python libs + pip
License: %{libs_license} AND Apache-2.0 AND ISC AND LGPL-2.1-only AND MPL-2.0 AND (Apache-2.0 OR BSD-2-Clause)
%endif
@@ -782,6 +794,7 @@ Provides: bundled(python3dist(pip)) = %{pip_version}
%pip_bundled_provides
Provides: bundled(python3dist(setuptools)) = %{setuptools_version}
%setuptools_bundled_provides
+Requires: ca-certificates
# License combined from Python libs + pip + setuptools
License: %{libs_license} AND Apache-2.0 AND ISC AND LGPL-2.1-only AND MPL-2.0 AND (Apache-2.0 OR BSD-2-Clause)
%endif
@@ -842,6 +855,16 @@ extension modules.
%openpgpverify -k2 -s1 -d0
%autosetup -S git_am -n Python-%{upstream_version}
+# Apply patches to pip
+# This is done unconditionally on rpmwheels
+# so that the applicability against the current pip version is always verified,
+# even though the resulting wheel only matters when rpmwheels are disabled.
+unzip -qq Lib/ensurepip/_bundled/pip-%{pip_version}-py3-none-any.whl
+# -p2 to compensate src/ prefix
+patch -p2 < %{SOURCE41}
+zip -rq Lib/ensurepip/_bundled/pip-%{pip_version}-py3-none-any.whl pip pip-%{pip_version}.dist-info
+rm -rf pip/ pip-%{pip_version}.dist-info/
+
# Verify the second level of bundled provides is up to date
# Arguably this should be done in %%check, but %%prep has a faster feedback loop
# setuptools.whl does not contain the vendored.txt files
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-19 11:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 11:12 [rpms/python3.13] epel9: When built with bundled pip.whl, patch bundled certifi within to use ca-certificates
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox