summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2024-01-27 16:01:04 +0100
committerMichał Górny <mgorny@gentoo.org>2024-01-27 21:33:04 +0100
commitde35fc5dbc38e4d0b493520b2a3296fb991dc09d (patch)
tree6c7a677296d1bf210926f8b881079e0b900a76dc /dev-python/psycopg
parentgui-wm/sway: 1.9-rc1 bump (diff)
downloadgentoo-de35fc5dbc38e4d0b493520b2a3296fb991dc09d.tar.gz
gentoo-de35fc5dbc38e4d0b493520b2a3296fb991dc09d.tar.bz2
gentoo-de35fc5dbc38e4d0b493520b2a3296fb991dc09d.zip
dev-python/psycopg: Support building the C backend
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python/psycopg')
-rw-r--r--dev-python/psycopg/psycopg-3.1.17.ebuild45
1 files changed, 39 insertions, 6 deletions
diff --git a/dev-python/psycopg/psycopg-3.1.17.ebuild b/dev-python/psycopg/psycopg-3.1.17.ebuild
index 5dc95f268c32..70302101bce9 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=( pypy3 python3_{10..12} )
@@ -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,22 @@ BDEPEND="
distutils_enable_tests pytest
-src_test() {
- # tests are lurking in top-level directory
+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 +93,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
}