Blame SPECS/python3.11-psycopg2.spec

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