%global python3_pkgversion 3.14 %bcond tests 1 %global srcname psycopg2 %global sum A PostgreSQL database adapter for Python %global desc Psycopg is the most popular PostgreSQL adapter for the Python \ programming language. At its core it fully implements the Python DB \ API 2.0 specifications. Several extensions allow access to many of the \ features offered by PostgreSQL. Summary: %{sum} Name: python%{python3_pkgversion}-%{srcname} Version: 2.9.10 Release: 3%{?dist} # The exceptions allow linking to OpenSSL and PostgreSQL's libpq License: LGPL-3.0-or-later WITH openvpn-openssl-exception Url: https://www.psycopg.org/ Source: https://github.com/psycopg/psycopg2/archive/%{version}/psycopg2-%{version}.tar.gz BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-setuptools BuildRequires: gcc BuildRequires: libpq-devel # For testsuite %if %{with tests} BuildRequires: postgresql-test-rpm-macros %endif # Remove test 'test_from_tables' for s390 architecture # from ./tests/test_types_extras.py Patch0: test_types_extras-2.9.3-test_from_tables.patch %description %{desc} %package -n python%{python3_pkgversion}-%{srcname}-tests Summary: A testsuite for %sum %{python3_pkgversion} Requires: python%{python3_pkgversion}-%{srcname} = %version-%release %description -n python%{python3_pkgversion}-%{srcname}-tests %desc This sub-package delivers set of tests for the adapter. %prep %setup -q -n psycopg2-%{version} # The patch is applied only for s390 architecture as # on other architectures the test works %ifarch s390x s390 %patch -P0 -p0 %endif %generate_buildrequires %pyproject_buildrequires %build %pyproject_wheel %check %if %{with tests} export PGTESTS_LOCALE=C.UTF-8 %postgresql_tests_run export PSYCOPG2_TESTDB=${PGTESTS_DATABASES##*:} export PSYCOPG2_TESTDB_HOST=$PGHOST export PSYCOPG2_TESTDB_PORT=$PGPORT cmd="import tests; tests.unittest.main(defaultTest='tests.test_suite')" %py3_test_envvars %python3 -c "$cmd" --verbose %endif %install %pyproject_install %pyproject_save_files -l psycopg2 # Upstream removed tests from the package so we need to add them manually cp -r tests/ %{buildroot}%{python3_sitearch}/%{srcname}/tests/ %py3_shebang_fix %{buildroot}%{python3_sitearch}/%{srcname}/tests/ %files -n python%{python3_pkgversion}-psycopg2 -f %{pyproject_files} %doc AUTHORS NEWS README.rst %files -n python%{python3_pkgversion}-%{srcname}-tests %{python3_sitearch}/psycopg2/tests %changelog * Tue Sep 9 2025 Tomáš Hrnčiar - 2.9.10-3 - Initial package Fedora contributions by: Ales Nezbeda Bill Nottingham Bohuslav Kabrda Charalampos Stratakis David Malcolm Dennis Gilmore Devrim Gündüz Filip Januš Honza Horak Ignacio Vazquez-Abrams Igor Gnatenko Jason L Tibbitts III Jesse Keating Jozef Mlich Lumír Balhar Miro Hrončok Ondřej Sloup Patrik Novotný Pavel Raiskup Petr Kubat Peter Robinson Todd Zullinger Tomas Hrnciar Tom Lane