Blame SPECS/python3.11-psycopg2.spec

e0da6b
%global __python3 /usr/bin/python3.11
e0da6b
%global python3_pkgversion 3.11
e0da6b
e0da6b
# RHEL python3.11: Python 3 and Python 3 debug enabled, both Python 2 builds disabled
e0da6b
%bcond_without python3
e0da6b
%bcond_without python3_debug
e0da6b
%bcond_with    python2
e0da6b
%bcond_with    python2_debug
e0da6b
e0da6b
%bcond_without tests
e0da6b
e0da6b
%global srcname	psycopg2
e0da6b
%global sum	A PostgreSQL database adapter for Python
e0da6b
%global desc	Psycopg is the most popular PostgreSQL adapter for the Python \
e0da6b
programming language. At its core it fully implements the Python DB \
e0da6b
API 2.0 specifications. Several extensions allow access to many of the \
e0da6b
features offered by PostgreSQL.
e0da6b
e0da6b
%global python_runtimes	\\\
e0da6b
	%{?with_python2:python2} \\\
e0da6b
	%{?with_python2_debug:python2-debug} \\\
e0da6b
	%{?with_python3:python%{python3_pkgversion}} \\\
e0da6b
	%{?with_python3_debug:python%{python3_pkgversion}d}
e0da6b
e0da6b
%{!?with_python2:%{!?with_python3:%{error:one python version needed}}}
e0da6b
e0da6b
# Python 2.5+ is not supported by Zope, so it does not exist in
e0da6b
# recent Fedora releases. That's why zope subpackage is disabled.
e0da6b
%global zope 0
e0da6b
%if %zope
e0da6b
%global ZPsycopgDAdir %{_localstatedir}/lib/zope/Products/ZPsycopgDA
e0da6b
%endif
e0da6b
e0da6b
e0da6b
Summary:	%{sum}
e0da6b
Name:     python%{python3_pkgversion}-%{srcname}
e0da6b
Version:	2.9.3
e0da6b
Release:	1%{?dist}
e0da6b
# The exceptions allow linking to OpenSSL and PostgreSQL's libpq
e0da6b
License:	LGPLv3+ with exceptions
e0da6b
Url:	    http://initd.org/psycopg/
e0da6b
e0da6b
Source0:	http://initd.org/psycopg/tarballs/PSYCOPG-2-8/psycopg2-%{version}.tar.gz
e0da6b
e0da6b
%{?with_python2:BuildRequires:	python2-devel python2-setuptools}
e0da6b
%{?with_python3:BuildRequires:	python%{python3_pkgversion}-devel python%{python3_pkgversion}-rpm-macros python%{python3_pkgversion}-setuptools}
e0da6b
%{?with_python2_debug:BuildRequires:	python2-debug}
e0da6b
%{?with_python3_debug:BuildRequires:	python%{python3_pkgversion}-debug}
e0da6b
e0da6b
BuildRequires:	gcc
e0da6b
BuildRequires:	libpq-devel
e0da6b
e0da6b
# For testsuite
e0da6b
%if %{with tests}
e0da6b
BuildRequires:	postgresql-test-rpm-macros
e0da6b
%endif
e0da6b
e0da6b
Conflicts:	python-psycopg2-zope < %{version}
e0da6b
e0da6b
# Remove test 'test_from_tables' for s390 architecture
e0da6b
# from ./tests/test_types_extras.py
e0da6b
Patch0: test_types_extras-2.9.3-test_from_tables.patch
e0da6b
e0da6b
%description
e0da6b
%{desc}
e0da6b
e0da6b
e0da6b
%if %{with python2}
e0da6b
%package -n python2-%{srcname}
e0da6b
%{?python_provide:%python_provide python2-%{srcname}}
e0da6b
Summary: %{sum} 2
e0da6b
e0da6b
%description -n python2-%{srcname}
e0da6b
%{desc}
e0da6b
e0da6b
e0da6b
%package -n python2-%{srcname}-tests
e0da6b
Summary: A testsuite for %sum 2
e0da6b
Requires: python2-%srcname = %version-%release
e0da6b
e0da6b
%description -n python2-%{srcname}-tests
e0da6b
%desc
e0da6b
This sub-package delivers set of tests for the adapter.
e0da6b
%endif
e0da6b
e0da6b
e0da6b
%if %{with python2_debug}
e0da6b
%package -n python2-%{srcname}-debug
e0da6b
Summary: A PostgreSQL database adapter for Python 2 (debug build)
e0da6b
# Require the base package, as we're sharing .py/.pyc files:
e0da6b
Requires:	python2-%{srcname} = %{version}-%{release}
e0da6b
%{?python_provide:%python_provide python2-%{srcname}-debug}
e0da6b
e0da6b
%description -n python2-%{srcname}-debug
e0da6b
This is a build of the psycopg PostgreSQL database adapter for the debug
e0da6b
build of Python 2.
e0da6b
%endif
e0da6b
e0da6b
e0da6b
%if %{with python3}
e0da6b
%package -n python%{python3_pkgversion}-%{srcname}-tests
e0da6b
Summary: A testsuite for %sum 2
e0da6b
Requires: python%{python3_pkgversion}-%{srcname} = %version-%release
e0da6b
e0da6b
%description -n python%{python3_pkgversion}-%{srcname}-tests
e0da6b
%desc
e0da6b
This sub-package delivers set of tests for the adapter.
e0da6b
%endif
e0da6b
e0da6b
e0da6b
%if %{with python3_debug}
e0da6b
%package -n python%{python3_pkgversion}-psycopg2-debug
e0da6b
Summary: A PostgreSQL database adapter for Python 3 (debug build)
e0da6b
# Require base python 3 package, as we're sharing .py/.pyc files:
e0da6b
Requires:	python%{python3_pkgversion}-psycopg2 = %{version}-%{release}
e0da6b
e0da6b
%description -n python%{python3_pkgversion}-%{srcname}-debug
e0da6b
This is a build of the psycopg PostgreSQL database adapter for the debug
e0da6b
build of Python 3.
e0da6b
%endif
e0da6b
e0da6b
e0da6b
%if %zope
e0da6b
%package zope
e0da6b
Summary:	Zope Database Adapter ZPsycopgDA
e0da6b
# The exceptions allow linking to OpenSSL and PostgreSQL's libpq
e0da6b
License:	GPLv2+ with exceptions or ZPLv1.0
e0da6b
Requires:	%{name} = %{version}-%{release}
e0da6b
Requires:	zope
e0da6b
e0da6b
%description zope
e0da6b
Zope Database Adapter for PostgreSQL, called ZPsycopgDA
e0da6b
%endif
e0da6b
e0da6b
e0da6b
%prep
e0da6b
%setup -q -n psycopg2-%{version}
e0da6b
e0da6b
# The patch is applied only for s390 architecture as 
e0da6b
# on other architectures the test works
e0da6b
%ifarch s390x s390
e0da6b
%patch0 -p0
e0da6b
%endif
e0da6b
e0da6b
%build
e0da6b
export CFLAGS=${RPM_OPT_FLAGS} LDFLAGS=${RPM_LD_FLAGS}
e0da6b
for python in %{python_runtimes} ; do
e0da6b
  $python setup.py build
e0da6b
done
e0da6b
e0da6b
%check
e0da6b
%if %{with tests}
e0da6b
export PGTESTS_LOCALE=C.UTF-8
e0da6b
%postgresql_tests_run
e0da6b
e0da6b
export PSYCOPG2_TESTDB=${PGTESTS_DATABASES##*:}
e0da6b
export PSYCOPG2_TESTDB_HOST=$PGHOST
e0da6b
export PSYCOPG2_TESTDB_PORT=$PGPORT
e0da6b
e0da6b
cmd="import tests; tests.unittest.main(defaultTest='tests.test_suite')"
e0da6b
e0da6b
%if %{with python2}
e0da6b
PYTHONPATH=%buildroot%python2_sitearch %__python2 -c "$cmd" --verbose
e0da6b
%endif
e0da6b
%if %{with python3}
e0da6b
PYTHONPATH=%buildroot%python3_sitearch %__python3 -c "$cmd" --verbose
e0da6b
%endif
e0da6b
%endif
e0da6b
e0da6b
e0da6b
%install
e0da6b
export CFLAGS=${RPM_OPT_FLAGS} LDFLAGS=${RPM_LD_FLAGS}
e0da6b
for python in %{python_runtimes} ; do
e0da6b
  $python setup.py install --no-compile --root %{buildroot}
e0da6b
done
e0da6b
e0da6b
# Upstream removed tests from the package so we need to add them manually
e0da6b
%if %{with python2}
e0da6b
cp -r tests/ %{buildroot}%{python2_sitearch}/%{srcname}/tests/
e0da6b
for i in `find %{buildroot}%{python2_sitearch}/%{srcname}/tests/ -iname "*.py"`; do
e0da6b
  sed -i 's|#!/usr/bin/env python|#!/usr/bin/python2|' $i
e0da6b
done
e0da6b
%endif
e0da6b
%if %{with python3}
e0da6b
cp -r tests/ %{buildroot}%{python3_sitearch}/%{srcname}/tests/
e0da6b
for i in `find %{buildroot}%{python3_sitearch}/%{srcname}/tests/ -iname "*.py"`; do
e0da6b
  sed -i 's|#!/usr/bin/env python|#!%{__python3}|' $i
e0da6b
done
e0da6b
%endif
e0da6b
e0da6b
%if %zope
e0da6b
%{__install} -d %{buildroot}%{ZPsycopgDAdir}
e0da6b
%{__cp} -pr ZPsycopgDA/* %{buildroot}%{ZPsycopgDAdir}
e0da6b
%endif
e0da6b
e0da6b
%if %{with python2}
e0da6b
%files -n python2-psycopg2
e0da6b
%license LICENSE
e0da6b
%doc AUTHORS NEWS README.rst
e0da6b
%dir %{python2_sitearch}/psycopg2
e0da6b
%{python2_sitearch}/psycopg2/*.py
e0da6b
%{python2_sitearch}/psycopg2/*.pyc
e0da6b
%{python2_sitearch}/psycopg2/_psycopg.so
e0da6b
%{python2_sitearch}/psycopg2/*.pyo
e0da6b
%{python2_sitearch}/psycopg2-%{version}-py2*.egg-info
e0da6b
e0da6b
e0da6b
%files -n python2-%{srcname}-tests
e0da6b
%{python2_sitearch}/psycopg2/tests
e0da6b
%endif
e0da6b
e0da6b
e0da6b
%if %{with python2_debug}
e0da6b
%files -n python2-%{srcname}-debug
e0da6b
%license LICENSE
e0da6b
%{python2_sitearch}/psycopg2/_psycopg_d.so
e0da6b
%endif
e0da6b
e0da6b
e0da6b
%if %{with python3}
e0da6b
%files -n python%{python3_pkgversion}-psycopg2
e0da6b
%license LICENSE
e0da6b
%doc AUTHORS NEWS README.rst
e0da6b
%dir %{python3_sitearch}/psycopg2
e0da6b
%{python3_sitearch}/psycopg2/*.py
e0da6b
%{python3_sitearch}/psycopg2/_psycopg.cpython-%{python3_version_nodots}[!d]*.so
e0da6b
%dir %{python3_sitearch}/psycopg2/__pycache__
e0da6b
%{python3_sitearch}/psycopg2/__pycache__/*.py{c,o}
e0da6b
%{python3_sitearch}/psycopg2-%{version}-py3*.egg-info
e0da6b
e0da6b
e0da6b
%files -n python%{python3_pkgversion}-%{srcname}-tests
e0da6b
%{python3_sitearch}/psycopg2/tests
e0da6b
%endif
e0da6b
e0da6b
e0da6b
%if %{with python3_debug}
e0da6b
%files -n python%{python3_pkgversion}-psycopg2-debug
e0da6b
%license LICENSE
e0da6b
%{python3_sitearch}/psycopg2/_psycopg.cpython-%{python3_version_nodots}d*.so
e0da6b
%endif
e0da6b
e0da6b
e0da6b
%if %zope
e0da6b
%files zope
e0da6b
%license LICENSE
e0da6b
%dir %{ZPsycopgDAdir}
e0da6b
%{ZPsycopgDAdir}/*.py
e0da6b
%{ZPsycopgDAdir}/*.pyo
e0da6b
%{ZPsycopgDAdir}/*.pyc
e0da6b
%{ZPsycopgDAdir}/dtml/*
e0da6b
%{ZPsycopgDAdir}/icons/*
e0da6b
%endif
e0da6b
e0da6b
e0da6b
%changelog
e0da6b
* Tue Nov 29 2022 Charalampos Stratakis <cstratak@redhat.com> - 2.9.3-1
e0da6b
- Initial package
e0da6b
- Fedora contributions by:
e0da6b
      Bill Nottingham <notting@fedoraproject.org>
e0da6b
      Charalampos Stratakis <cstratak@redhat.com>
e0da6b
      David Malcolm <dmalcolm@redhat.com>
e0da6b
      Dennis Gilmore <dennis@ausil.us>
e0da6b
      Devrim GÜNDÜZ <devrim@fedoraproject.org>
e0da6b
      Filip Januš <fjanus@redhat.com>
e0da6b
      Honza Horak <hhorak@redhat.com>
e0da6b
      Ignacio Vazquez-Abrams <ivazquez@fedoraproject.org>
e0da6b
      Igor Gnatenko <ignatenkobrain@fedoraproject.org>
e0da6b
      Jason Tibbitts <tibbs@math.uh.edu>
e0da6b
      Jesse Keating <jkeating@fedoraproject.org>
e0da6b
      Jozef Mlich <jmlich@redhat.com>
e0da6b
      Lumir Balhar <lbalhar@redhat.com>
e0da6b
      Miro Hrončok <miro@hroncok.cz>
e0da6b
      Ondřej Sloup <ondrej.sloup@protonmail.com>
e0da6b
      Patrik Novotný <panovotn@redhat.com>
e0da6b
      Pavel Raiskup <praiskup@redhat.com>
e0da6b
      Peter Robinson <pbrobinson@fedoraproject.org>
e0da6b
      Petr Kubat <pkubat@redhat.com>
e0da6b
      Slavek Kabrda <bkabrda@redhat.com>
e0da6b
      Todd Zullinger <tmz@fedoraproject.org>
e0da6b
      Tomas Hrnciar <thrnciar@redhat.com>
e0da6b
      Tom Lane <tgl@fedoraproject.org>