Blame SPECS/python3.11-psycopg2.spec

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