From 6eba187340fb9cc0563d7a93eed49c99a80add29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Thu, 9 Mar 2023 10:38:58 +0700 Subject: [PATCH] python3-certifi: use system cacert --- .../patches/system-cacert.patch | 53 +++++++++++++++++++ srcpkgs/python3-certifi/template | 11 ++-- 2 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 srcpkgs/python3-certifi/patches/system-cacert.patch diff --git a/srcpkgs/python3-certifi/patches/system-cacert.patch b/srcpkgs/python3-certifi/patches/system-cacert.patch new file mode 100644 index 00000000000..7e41029aa1e --- /dev/null +++ b/srcpkgs/python3-certifi/patches/system-cacert.patch @@ -0,0 +1,53 @@ +--- 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, diff --git a/srcpkgs/python3-certifi/template b/srcpkgs/python3-certifi/template index f58123986d6..c494c972164 100644 --- a/srcpkgs/python3-certifi/template +++ b/srcpkgs/python3-certifi/template @@ -1,7 +1,7 @@ # Template file for 'python3-certifi' pkgname=python3-certifi version=2022.09.24 -revision=2 +revision=3 build_style=python3-module hostmakedepends="python3-setuptools" depends="python3" @@ -12,7 +12,10 @@ homepage="https://certifi.io" distfiles="https://github.com/certifi/python-certifi/archive/${version}.tar.gz" checksum=8c1db7f2a3b272e8a90b2e1910763930fa81e2512fbb96cb7a25787d63765c78 -do_check() { - cd build/lib - python3 -c 'import certifi as m; print(m)' +post_extract() { + rm -f certifi/cacert.pem +} + +do_check() { + python3 -m unittest }