%global package_name psycopg %global src_name %{package_name}3 %global libpq_ver 14 Name: python-%{src_name} Version: 3.0.11 Release: 1%{?dist} Summary: Psycopg 3 is a modern implementation of a PostgreSQL adapter for Python License: LGPLv3 URL: https://www.psycopg.org/%{src_name}/ Source0: https://github.com/%{package_name}/%{package_name}/archive/refs/tags/%{version}.tar.gz Source1: https://raw.githubusercontent.com/postgres/postgres/REL_%{libpq_ver}_STABLE/doc/src/sgml/libpq.sgml BuildRequires: python3-devel Requires: pkgconfig(libpq) # Required for running tests BuildRequires: pkgconfig(libpq) # Required for documentation BuildRequires: gcc BuildArch: noarch %description Psycopg 3 is a PostgreSQL database adapter for the Python programming language. Psycopg 3 presents a familiar interface for everyone who has used Psycopg 2 or any other DB-API 2.0 database adapter, but allows to use more modern PostgreSQL and Python features. %prep %autosetup -p1 -n %{package_name}-%{version}/%{package_name} # Copy libpq needed for documentation cp %{SOURCE1} . # Remove unused packages for tests # and versions not available in Fedora sed -i '/pproxy/d' setup.py sed -i '/pytest-cov/d' setup.py # This line removes the version, since it is not supported # in Fedora, introduces breaking changes in package sed -i -r 's/(pytest-asyncio).*",/\1",/' setup.py # Remove version for package for docs # not available in Fedora sed -i '/furo/d' setup.py # Tests fail when installed sed -i '/dnspython/d' setup.py # Remove package from docs sed -i '/import %{package_name}/d' ../docs/conf.py sed -i 's/%{package_name}.__version__/"%{version}"/' ../docs/conf.py sed -i '/import %{package_name}/d' ../docs/lib/pg3_docs.py sed -i '/recover_defined_module(%{package_name})/d' ../docs/lib/pg3_docs.py %generate_buildrequires %pyproject_buildrequires -x test -x docs %build %pyproject_wheel %install %pyproject_install %pyproject_save_files %{package_name} # Create configuration file which corrects # the breaking change caused by the version of pytest-asyncio echo " [pytest] asyncio_mode = auto" >> ../tests/pytest.ini # Remove failing tests rm ../tests/test_typing.py rm ../tests/test_module.py find ../tests/pool/ ! -name 'fix_pool.py' -type f -exec rm -f {} + %check %pytest ../tests/ # Add libpq sgml file for documentation mkdir ../docs/_build mkdir ../docs/_build/doctrees mv libpq.sgml ../docs/_build/doctrees/libpq-%{libpq_ver}.sgml make man -C ../docs %files -n python-%{src_name} -f %{pyproject_files} %doc ../docs/_build/man %license LICENSE.txt %changelog * Tue Apr 19 2022 Ondrej Sloup - 5.2.4 - Create package from git source (#1949dee)