%global package_name psycopg %global src_name %{package_name}3 %global libpq_ver 14 %global _description %{expand: 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.} 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: make BuildArch: noarch %description %_description %package -n python3-%{src_name} Summary: %{Summary} %description -n python3-%{src_name} %_description %prep %autosetup -p1 -n %{package_name}-%{version}/%{package_name} # libpq.sgml is needed as part of the documentation # If not present, documentation build will try to download and fail 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} # Add libpq sgml file for documentation mkdir ../docs/_build mkdir ../docs/_build/doctrees mv libpq.sgml ../docs/_build/doctrees/libpq-%{libpq_ver}.sgml # Build the documentation make man -C ../docs # Move the documentation in correct directory and zip it cp ../docs/_build/man/psycopg.1 psycopg.3 # Potrebuju vytvorit tar a ten tam hodit, coz musim udelat stejne separe tar -cvzf psycopg.3.gz psycopg.3 install -D -p -m 644 psycopg.3.gz %{buildroot}%{_mandir}/man3/psycopg.3.gz # 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/ %files -n python-%{src_name} -f %{pyproject_files} %doc %{_mandir}/man3/psycopg.3.gz %license LICENSE.txt %changelog * Thu Apr 28 2022 Ondrej Sloup - 3.0.11-1 - Create package from git source (#2079251)