diff options
| author | Liguros - Gitlab CI/CD [develop] <gitlab@liguros.net> | 2024-01-28 09:49:49 +0000 |
|---|---|---|
| committer | Liguros - Gitlab CI/CD [develop] <gitlab@liguros.net> | 2024-01-28 09:49:49 +0000 |
| commit | 943fdd0100f2d0ca460f6bb9799e119fbd77a2aa (patch) | |
| tree | 5d4a27f122d2ea95a479fc05b7669ed89faa761c /dev-python/psycopg | |
| parent | 3fba14f8e2c311e84e090f28f0bbf40b23ce16b2 (diff) | |
| download | baldeagleos-repo-943fdd0100f2d0ca460f6bb9799e119fbd77a2aa.tar.gz baldeagleos-repo-943fdd0100f2d0ca460f6bb9799e119fbd77a2aa.tar.xz baldeagleos-repo-943fdd0100f2d0ca460f6bb9799e119fbd77a2aa.zip | |
Adding metadata
Diffstat (limited to 'dev-python/psycopg')
| -rw-r--r-- | dev-python/psycopg/files/psycopg-3.1.17-musl.patch | 34 | ||||
| -rw-r--r-- | dev-python/psycopg/psycopg-3.1.17.ebuild | 50 |
2 files changed, 78 insertions, 6 deletions
diff --git a/dev-python/psycopg/files/psycopg-3.1.17-musl.patch b/dev-python/psycopg/files/psycopg-3.1.17-musl.patch new file mode 100644 index 000000000000..ca1689931ed8 --- /dev/null +++ b/dev-python/psycopg/files/psycopg-3.1.17-musl.patch @@ -0,0 +1,34 @@ +From eeb662bf89e9ffdb3e6fc40eb30d0b53e0b4bece Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org> +Date: Sat, 27 Jan 2024 15:28:34 +0100 +Subject: [PATCH] fix: add `libc.so` fallback for musl systems to the ctypes + impl + +Add a fallback to `libc.so` library name to fix loading the ctypes +implementation on musl systems. On musl, `find_library("c")` does +not work (the problem has been reported to CPython in 2014, and has not +been resolved yet), causing the module to fail on `assert libcname`. +Instead, add a fallback to using `libc.so` and let ctypes raise +an exception if such a library does not exist. +--- + psycopg/psycopg/pq/_pq_ctypes.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/psycopg/psycopg/pq/_pq_ctypes.py b/psycopg/psycopg/pq/_pq_ctypes.py +index 9d4dd181..3ecff080 100644 +--- a/psycopg/psycopg/pq/_pq_ctypes.py ++++ b/psycopg/psycopg/pq/_pq_ctypes.py +@@ -28,8 +28,8 @@ class FILE(Structure): + FILE_ptr = POINTER(FILE) + + if sys.platform == "linux": +- libcname = ctypes.util.find_library("c") +- assert libcname ++ # find_library("c") does not work on musl, fall back to libc.so instead ++ libcname = ctypes.util.find_library("c") or "libc.so" + libc = ctypes.cdll.LoadLibrary(libcname) + + fdopen = libc.fdopen +-- +2.43.0 + diff --git a/dev-python/psycopg/psycopg-3.1.17.ebuild b/dev-python/psycopg/psycopg-3.1.17.ebuild index e740144c65f0..68148e58613f 100644 --- a/dev-python/psycopg/psycopg-3.1.17.ebuild +++ b/dev-python/psycopg/psycopg-3.1.17.ebuild @@ -3,6 +3,7 @@ EAPI=8 +DISTUTILS_EXT=1 DISTUTILS_USE_PEP517=setuptools PYTHON_COMPAT=( python3_{8,9,10,11,12} pypy3 ) @@ -18,20 +19,29 @@ SRC_URI=" https://github.com/psycopg/psycopg/archive/${PV}.tar.gz -> ${P}.gh.tar.gz " -S=${WORKDIR}/${P}/psycopg LICENSE="LGPL-3+" SLOT="0" KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ppc ppc64 ~riscv ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos" +IUSE="+native-extensions" DEPEND=" - >=dev-db/postgresql-8.1:* + native-extensions? ( + >=dev-db/postgresql-8.1:= + ) + !native-extensions? ( + >=dev-db/postgresql-8.1:* + ) " RDEPEND=" ${DEPEND} >=dev-python/typing-extensions-4.1[${PYTHON_USEDEP}] " BDEPEND=" + native-extensions? ( + dev-python/cython[${PYTHON_USEDEP}] + dev-python/tomli[${PYTHON_USEDEP}] + ) test? ( >=dev-db/postgresql-8.1[server] dev-python/anyio[${PYTHON_USEDEP}] @@ -41,9 +51,27 @@ BDEPEND=" distutils_enable_tests pytest -src_test() { - # tests are lurking in top-level directory +PATCHES=( + # https://github.com/psycopg/psycopg/pull/725 + "${FILESDIR}/${P}-musl.patch" +) + +python_compile() { + # Python code + ctypes backend + cd psycopg || die + distutils-r1_python_compile + + # optional C backend + if use native-extensions && [[ ${EPYTHON} != pypy3 ]]; then + local DISTUTILS_USE_PEP517=standalone + cd ../psycopg_c || die + distutils-r1_python_compile + fi cd .. || die +} + +src_test() { + rm -r psycopg{,_c} || die initdb -D "${T}"/pgsql || die # TODO: random port @@ -70,7 +98,17 @@ python_test() { tests/test_dns_srv.py::test_srv ) + local impls=( python ) + if use native-extensions && [[ ${EPYTHON} != pypy3 ]]; then + impls+=( c ) + fi + local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 - # leak and timing tests are fragile whereas slow tests are slow - epytest -p anyio -k "not leak" -m "not timing and not slow" + local -x PSYCOPG_IMPL + for PSYCOPG_IMPL in "${impls[@]}"; do + einfo "Testing with ${PSYCOPG_IMPL} implementation ..." + # leak and timing tests are fragile whereas slow tests are slow + epytest -p anyio -k "not leak" \ + -m "not timing and not slow and not flakey" + done } |
