From 1351c769ac4cc50be0739d58f8f051632f5b34f8 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 9 May 2023 05:26:43 +0000 Subject: [PATCH] import python3.11-psycopg2-2.9.3-1.el9 --- .gitignore | 1 + .python3.11-psycopg2.metadata | 1 + ..._types_extras-2.9.3-test_from_tables.patch | 54 ++++ SPECS/python3.11-psycopg2.spec | 282 ++++++++++++++++++ 4 files changed, 338 insertions(+) create mode 100644 .gitignore create mode 100644 .python3.11-psycopg2.metadata create mode 100644 SOURCES/test_types_extras-2.9.3-test_from_tables.patch create mode 100644 SPECS/python3.11-psycopg2.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d9ced5f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/psycopg2-2.9.3.tar.gz diff --git a/.python3.11-psycopg2.metadata b/.python3.11-psycopg2.metadata new file mode 100644 index 0000000..23aa343 --- /dev/null +++ b/.python3.11-psycopg2.metadata @@ -0,0 +1 @@ +87802252c3ad9a89b1c5b828ff7fd4055cf98e0f SOURCES/psycopg2-2.9.3.tar.gz diff --git a/SOURCES/test_types_extras-2.9.3-test_from_tables.patch b/SOURCES/test_types_extras-2.9.3-test_from_tables.patch new file mode 100644 index 0000000..750e479 --- /dev/null +++ b/SOURCES/test_types_extras-2.9.3-test_from_tables.patch @@ -0,0 +1,54 @@ +--- tests/test_types_extras.py-orig 2021-12-29 13:51:56.000000000 +0100 ++++ tests/test_types_extras.py 2022-05-17 11:23:12.476001589 +0200 +@@ -616,51 +616,6 @@ + curs.execute("select (1,2)::type_ii") + self.assertRaises(psycopg2.DataError, curs.fetchone) + +- @slow +- @skip_if_no_composite +- @skip_before_postgres(8, 4) +- def test_from_tables(self): +- curs = self.conn.cursor() +- curs.execute("""create table ctest1 ( +- id integer primary key, +- temp int, +- label varchar +- );""") +- +- curs.execute("""alter table ctest1 drop temp;""") +- +- curs.execute("""create table ctest2 ( +- id serial primary key, +- label varchar, +- test_id integer references ctest1(id) +- );""") +- +- curs.execute("""insert into ctest1 (id, label) values +- (1, 'test1'), +- (2, 'test2');""") +- curs.execute("""insert into ctest2 (label, test_id) values +- ('testa', 1), +- ('testb', 1), +- ('testc', 2), +- ('testd', 2);""") +- +- psycopg2.extras.register_composite("ctest1", curs) +- psycopg2.extras.register_composite("ctest2", curs) +- +- curs.execute(""" +- select ctest1, array_agg(ctest2) as test2s +- from ( +- select ctest1, ctest2 +- from ctest1 inner join ctest2 on ctest1.id = ctest2.test_id +- order by ctest1.id, ctest2.label +- ) x group by ctest1;""") +- +- r = curs.fetchone() +- self.assertEqual(r[0], (1, 'test1')) +- self.assertEqual(r[1], [(1, 'testa', 1), (2, 'testb', 1)]) +- r = curs.fetchone() +- self.assertEqual(r[0], (2, 'test2')) +- self.assertEqual(r[1], [(3, 'testc', 2), (4, 'testd', 2)]) + + @skip_if_no_composite + def test_non_dbapi_connection(self): diff --git a/SPECS/python3.11-psycopg2.spec b/SPECS/python3.11-psycopg2.spec new file mode 100644 index 0000000..569b090 --- /dev/null +++ b/SPECS/python3.11-psycopg2.spec @@ -0,0 +1,282 @@ +%global __python3 /usr/bin/python3.11 +%global python3_pkgversion 3.11 + +# RHEL python3.11: Python 3 and Python 3 debug enabled, both Python 2 builds disabled +%bcond_without python3 +%bcond_without python3_debug +%bcond_with python2 +%bcond_with python2_debug + +%bcond_without tests + +%global srcname psycopg2 +%global sum A PostgreSQL database adapter for Python +%global desc Psycopg is the most popular PostgreSQL adapter for the Python \ +programming language. At its core it fully implements the Python DB \ +API 2.0 specifications. Several extensions allow access to many of the \ +features offered by PostgreSQL. + +%global python_runtimes \\\ + %{?with_python2:python2} \\\ + %{?with_python2_debug:python2-debug} \\\ + %{?with_python3:python%{python3_pkgversion}} \\\ + %{?with_python3_debug:python%{python3_pkgversion}d} + +%{!?with_python2:%{!?with_python3:%{error:one python version needed}}} + +# Python 2.5+ is not supported by Zope, so it does not exist in +# recent Fedora releases. That's why zope subpackage is disabled. +%global zope 0 +%if %zope +%global ZPsycopgDAdir %{_localstatedir}/lib/zope/Products/ZPsycopgDA +%endif + + +Summary: %{sum} +Name: python%{python3_pkgversion}-%{srcname} +Version: 2.9.3 +Release: 1%{?dist} +# The exceptions allow linking to OpenSSL and PostgreSQL's libpq +License: LGPLv3+ with exceptions +Url: http://initd.org/psycopg/ + +Source0: http://initd.org/psycopg/tarballs/PSYCOPG-2-8/psycopg2-%{version}.tar.gz + +%{?with_python2:BuildRequires: python2-devel python2-setuptools} +%{?with_python3:BuildRequires: python%{python3_pkgversion}-devel python%{python3_pkgversion}-rpm-macros python%{python3_pkgversion}-setuptools} +%{?with_python2_debug:BuildRequires: python2-debug} +%{?with_python3_debug:BuildRequires: python%{python3_pkgversion}-debug} + +BuildRequires: gcc +BuildRequires: libpq-devel + +# For testsuite +%if %{with tests} +BuildRequires: postgresql-test-rpm-macros +%endif + +Conflicts: python-psycopg2-zope < %{version} + +# Remove test 'test_from_tables' for s390 architecture +# from ./tests/test_types_extras.py +Patch0: test_types_extras-2.9.3-test_from_tables.patch + +%description +%{desc} + + +%if %{with python2} +%package -n python2-%{srcname} +%{?python_provide:%python_provide python2-%{srcname}} +Summary: %{sum} 2 + +%description -n python2-%{srcname} +%{desc} + + +%package -n python2-%{srcname}-tests +Summary: A testsuite for %sum 2 +Requires: python2-%srcname = %version-%release + +%description -n python2-%{srcname}-tests +%desc +This sub-package delivers set of tests for the adapter. +%endif + + +%if %{with python2_debug} +%package -n python2-%{srcname}-debug +Summary: A PostgreSQL database adapter for Python 2 (debug build) +# Require the base package, as we're sharing .py/.pyc files: +Requires: python2-%{srcname} = %{version}-%{release} +%{?python_provide:%python_provide python2-%{srcname}-debug} + +%description -n python2-%{srcname}-debug +This is a build of the psycopg PostgreSQL database adapter for the debug +build of Python 2. +%endif + + +%if %{with python3} +%package -n python%{python3_pkgversion}-%{srcname}-tests +Summary: A testsuite for %sum 2 +Requires: python%{python3_pkgversion}-%{srcname} = %version-%release + +%description -n python%{python3_pkgversion}-%{srcname}-tests +%desc +This sub-package delivers set of tests for the adapter. +%endif + + +%if %{with python3_debug} +%package -n python%{python3_pkgversion}-psycopg2-debug +Summary: A PostgreSQL database adapter for Python 3 (debug build) +# Require base python 3 package, as we're sharing .py/.pyc files: +Requires: python%{python3_pkgversion}-psycopg2 = %{version}-%{release} + +%description -n python%{python3_pkgversion}-%{srcname}-debug +This is a build of the psycopg PostgreSQL database adapter for the debug +build of Python 3. +%endif + + +%if %zope +%package zope +Summary: Zope Database Adapter ZPsycopgDA +# The exceptions allow linking to OpenSSL and PostgreSQL's libpq +License: GPLv2+ with exceptions or ZPLv1.0 +Requires: %{name} = %{version}-%{release} +Requires: zope + +%description zope +Zope Database Adapter for PostgreSQL, called ZPsycopgDA +%endif + + +%prep +%setup -q -n psycopg2-%{version} + +# The patch is applied only for s390 architecture as +# on other architectures the test works +%ifarch s390x s390 +%patch0 -p0 +%endif + +%build +export CFLAGS=${RPM_OPT_FLAGS} LDFLAGS=${RPM_LD_FLAGS} +for python in %{python_runtimes} ; do + $python setup.py build +done + +%check +%if %{with tests} +export PGTESTS_LOCALE=C.UTF-8 +%postgresql_tests_run + +export PSYCOPG2_TESTDB=${PGTESTS_DATABASES##*:} +export PSYCOPG2_TESTDB_HOST=$PGHOST +export PSYCOPG2_TESTDB_PORT=$PGPORT + +cmd="import tests; tests.unittest.main(defaultTest='tests.test_suite')" + +%if %{with python2} +PYTHONPATH=%buildroot%python2_sitearch %__python2 -c "$cmd" --verbose +%endif +%if %{with python3} +PYTHONPATH=%buildroot%python3_sitearch %__python3 -c "$cmd" --verbose +%endif +%endif + + +%install +export CFLAGS=${RPM_OPT_FLAGS} LDFLAGS=${RPM_LD_FLAGS} +for python in %{python_runtimes} ; do + $python setup.py install --no-compile --root %{buildroot} +done + +# Upstream removed tests from the package so we need to add them manually +%if %{with python2} +cp -r tests/ %{buildroot}%{python2_sitearch}/%{srcname}/tests/ +for i in `find %{buildroot}%{python2_sitearch}/%{srcname}/tests/ -iname "*.py"`; do + sed -i 's|#!/usr/bin/env python|#!/usr/bin/python2|' $i +done +%endif +%if %{with python3} +cp -r tests/ %{buildroot}%{python3_sitearch}/%{srcname}/tests/ +for i in `find %{buildroot}%{python3_sitearch}/%{srcname}/tests/ -iname "*.py"`; do + sed -i 's|#!/usr/bin/env python|#!%{__python3}|' $i +done +%endif + +%if %zope +%{__install} -d %{buildroot}%{ZPsycopgDAdir} +%{__cp} -pr ZPsycopgDA/* %{buildroot}%{ZPsycopgDAdir} +%endif + +%if %{with python2} +%files -n python2-psycopg2 +%license LICENSE +%doc AUTHORS NEWS README.rst +%dir %{python2_sitearch}/psycopg2 +%{python2_sitearch}/psycopg2/*.py +%{python2_sitearch}/psycopg2/*.pyc +%{python2_sitearch}/psycopg2/_psycopg.so +%{python2_sitearch}/psycopg2/*.pyo +%{python2_sitearch}/psycopg2-%{version}-py2*.egg-info + + +%files -n python2-%{srcname}-tests +%{python2_sitearch}/psycopg2/tests +%endif + + +%if %{with python2_debug} +%files -n python2-%{srcname}-debug +%license LICENSE +%{python2_sitearch}/psycopg2/_psycopg_d.so +%endif + + +%if %{with python3} +%files -n python%{python3_pkgversion}-psycopg2 +%license LICENSE +%doc AUTHORS NEWS README.rst +%dir %{python3_sitearch}/psycopg2 +%{python3_sitearch}/psycopg2/*.py +%{python3_sitearch}/psycopg2/_psycopg.cpython-%{python3_version_nodots}[!d]*.so +%dir %{python3_sitearch}/psycopg2/__pycache__ +%{python3_sitearch}/psycopg2/__pycache__/*.py{c,o} +%{python3_sitearch}/psycopg2-%{version}-py3*.egg-info + + +%files -n python%{python3_pkgversion}-%{srcname}-tests +%{python3_sitearch}/psycopg2/tests +%endif + + +%if %{with python3_debug} +%files -n python%{python3_pkgversion}-psycopg2-debug +%license LICENSE +%{python3_sitearch}/psycopg2/_psycopg.cpython-%{python3_version_nodots}d*.so +%endif + + +%if %zope +%files zope +%license LICENSE +%dir %{ZPsycopgDAdir} +%{ZPsycopgDAdir}/*.py +%{ZPsycopgDAdir}/*.pyo +%{ZPsycopgDAdir}/*.pyc +%{ZPsycopgDAdir}/dtml/* +%{ZPsycopgDAdir}/icons/* +%endif + + +%changelog +* Tue Nov 29 2022 Charalampos Stratakis - 2.9.3-1 +- Initial package +- Fedora contributions by: + Bill Nottingham + Charalampos Stratakis + David Malcolm + Dennis Gilmore + Devrim GÜNDÜZ + Filip Januš + Honza Horak + Ignacio Vazquez-Abrams + Igor Gnatenko + Jason Tibbitts + Jesse Keating + Jozef Mlich + Lumir Balhar + Miro Hrončok + Ondřej Sloup + Patrik Novotný + Pavel Raiskup + Peter Robinson + Petr Kubat + Slavek Kabrda + Todd Zullinger + Tomas Hrnciar + Tom Lane