Blame SPECS/python3.11-psycopg2.spec

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