From 4f80d1b9833b59ea9e7b875596b6b37e4b6de780 Mon Sep 17 00:00:00 2001 From: MSVSphere Packaging Team Date: Wed, 3 Apr 2024 16:55:41 +0300 Subject: [PATCH] import python-psycopg2-2.7.5-8.module+el8.9.0+19487+7dc18407 --- .gitignore | 1 + .python-psycopg2.metadata | 1 + SOURCES/psycopg2_get_result_async.patch | 470 ++++++++++++++++++ SPECS/python-psycopg2.spec | 607 ++++++++++++++++++++++++ 4 files changed, 1079 insertions(+) create mode 100644 .gitignore create mode 100644 .python-psycopg2.metadata create mode 100644 SOURCES/psycopg2_get_result_async.patch create mode 100644 SPECS/python-psycopg2.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..88ce767 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/psycopg2-2.7.5.tar.gz diff --git a/.python-psycopg2.metadata b/.python-psycopg2.metadata new file mode 100644 index 0000000..93c132d --- /dev/null +++ b/.python-psycopg2.metadata @@ -0,0 +1 @@ +4f77e3efcf9a0970be5120352274315f7bd1c754 SOURCES/psycopg2-2.7.5.tar.gz diff --git a/SOURCES/psycopg2_get_result_async.patch b/SOURCES/psycopg2_get_result_async.patch new file mode 100644 index 0000000..b4f07dd --- /dev/null +++ b/SOURCES/psycopg2_get_result_async.patch @@ -0,0 +1,470 @@ +Only in psycopg2-2.7.5_patched/: cscope.in.out +Only in psycopg2-2.7.5_patched/: cscope.out +Only in psycopg2-2.7.5_patched/: cscope.po.out +diff -ur psycopg2-2.7.5/psycopg/connection.h psycopg2-2.7.5_patched/psycopg/connection.h +--- psycopg2-2.7.5/psycopg/connection.h 2018-06-17 18:07:41.000000000 +0200 ++++ psycopg2-2.7.5_patched/psycopg/connection.h 2023-06-27 14:47:59.000000000 +0200 +@@ -108,6 +108,7 @@ + * for a green connection. If NULL, the connection is idle. */ + PyObject *async_cursor; + int async_status; /* asynchronous execution status */ ++ PGresult *pgres; + + /* notice processing */ + PyObject *notice_list; +diff -ur psycopg2-2.7.5/psycopg/connection_int.c psycopg2-2.7.5_patched/psycopg/connection_int.c +--- psycopg2-2.7.5/psycopg/connection_int.c 2018-06-17 18:07:41.000000000 +0200 ++++ psycopg2-2.7.5_patched/psycopg/connection_int.c 2023-07-03 12:51:23.000000000 +0200 +@@ -891,11 +891,14 @@ + + /* Advance to the next state after a call to a pq_is_busy* function */ + static int +-_conn_poll_advance_read(connectionObject *self, int busy) ++_conn_poll_advance_read(connectionObject *self) + { +- int res; ++ int res, busy; + + Dprintf("conn_poll: poll reading"); ++ ++ busy = pq_get_result_async(self); ++ + switch (busy) { + case 0: /* result is ready */ + res = PSYCO_POLL_OK; +@@ -909,7 +912,7 @@ + res = PSYCO_POLL_ERROR; + break; + default: +- Dprintf("conn_poll: unexpected result from pq_is_busy: %d", busy); ++ Dprintf("conn_poll: unexpected result from pq_get_result_async: %d", busy); + res = PSYCO_POLL_ERROR; + break; + } +@@ -935,21 +938,21 @@ + case ASYNC_READ: + Dprintf("conn_poll: async_status = ASYNC_READ"); + if (self->async) { +- res = _conn_poll_advance_read(self, pq_is_busy(self)); ++ res = _conn_poll_advance_read(self); + } + else { + /* we are a green connection being polled as result of a query. + this means that our caller has the lock and we are being called + from the callback. If we tried to acquire the lock now it would + be a deadlock. */ +- res = _conn_poll_advance_read(self, pq_is_busy_locked(self)); ++ res = _conn_poll_advance_read(self); + } + break; + + case ASYNC_DONE: + Dprintf("conn_poll: async_status = ASYNC_DONE"); + /* We haven't asked anything: just check for notifications. */ +- res = _conn_poll_advance_read(self, pq_is_busy(self)); ++ res = _conn_poll_advance_read(self); + break; + + default: +@@ -972,7 +975,6 @@ + _conn_poll_setup_async(connectionObject *self) + { + int res = PSYCO_POLL_ERROR; +- PGresult *pgres; + + switch (self->status) { + case CONN_STATUS_CONNECTING: +@@ -1023,12 +1025,11 @@ + res = _conn_poll_query(self); + if (res == PSYCO_POLL_OK) { + res = PSYCO_POLL_ERROR; +- pgres = pq_get_last_result(self); +- if (pgres == NULL || PQresultStatus(pgres) != PGRES_COMMAND_OK ) { ++ if (self->pgres == NULL || PQresultStatus(self->pgres) != PGRES_COMMAND_OK ) { + PyErr_SetString(OperationalError, "can't set datestyle to ISO"); + break; + } +- CLEARPGRES(pgres); ++ CLEARPGRES(self->pgres); + + Dprintf("conn_poll: status -> CONN_STATUS_READY"); + self->status = CONN_STATUS_READY; +@@ -1089,8 +1090,9 @@ + } + + curs = (cursorObject *)py_curs; +- CLEARPGRES(curs->pgres); +- curs->pgres = pq_get_last_result(self); ++ PQclear(curs->pgres); ++ curs->pgres = self->pgres; ++ self->pgres = NULL; + + /* fetch the tuples (if there are any) and build the result. We + * don't care if pq_fetch return 0 or 1, but if there was an error, +diff -ur psycopg2-2.7.5/psycopg/cursor_type.c psycopg2-2.7.5_patched/psycopg/cursor_type.c +--- psycopg2-2.7.5/psycopg/cursor_type.c 2018-06-17 18:07:41.000000000 +0200 ++++ psycopg2-2.7.5_patched/psycopg/cursor_type.c 2023-06-27 15:08:58.000000000 +0200 +@@ -49,7 +49,6 @@ + static PyObject * + psyco_curs_close(cursorObject *self) + { +- EXC_IF_ASYNC_IN_PROGRESS(self, close); + + if (self->closed) { + goto exit; +@@ -59,6 +58,8 @@ + char buffer[128]; + PGTransactionStatusType status; + ++ EXC_IF_ASYNC_IN_PROGRESS(self, close_named); ++ + if (!self->query) { + Dprintf("skipping named cursor close because unused"); + goto close; +diff -ur psycopg2-2.7.5/psycopg/green.c psycopg2-2.7.5_patched/psycopg/green.c +--- psycopg2-2.7.5/psycopg/green.c 2018-06-17 18:07:41.000000000 +0200 ++++ psycopg2-2.7.5_patched/psycopg/green.c 2023-06-27 15:10:35.000000000 +0200 +@@ -177,10 +177,12 @@ + goto end; + } + +- /* Now we can read the data without fear of blocking. */ +- result = pq_get_last_result(conn); ++ /* the result is now in the connection: take its ownership */ ++ result = conn->pgres; ++ conn->pgres = NULL; + + end: ++ CLEARPGRES(conn->pgres); + conn->async_status = ASYNC_DONE; + Py_CLEAR(conn->async_cursor); + return result; +diff -ur psycopg2-2.7.5/psycopg/pqpath.c psycopg2-2.7.5_patched/psycopg/pqpath.c +--- psycopg2-2.7.5/psycopg/pqpath.c 2018-06-17 18:07:41.000000000 +0200 ++++ psycopg2-2.7.5_patched/psycopg/pqpath.c 2023-07-03 12:39:47.000000000 +0200 +@@ -842,80 +842,6 @@ + return rv; + } + +- +-/* pq_is_busy - consume input and return connection status +- +- a status of 1 means that a call to pq_fetch will block, while a status of 0 +- means that there is data available to be collected. -1 means an error, the +- exception will be set accordingly. +- +- this function locks the connection object +- this function call Py_*_ALLOW_THREADS macros */ +- +-int +-pq_is_busy(connectionObject *conn) +-{ +- int res; +- Dprintf("pq_is_busy: consuming input"); +- +- Py_BEGIN_ALLOW_THREADS; +- pthread_mutex_lock(&(conn->lock)); +- +- if (PQconsumeInput(conn->pgconn) == 0) { +- Dprintf("pq_is_busy: PQconsumeInput() failed"); +- pthread_mutex_unlock(&(conn->lock)); +- Py_BLOCK_THREADS; +- +- /* if the libpq says pgconn is lost, close the py conn */ +- if (CONNECTION_BAD == PQstatus(conn->pgconn)) { +- conn->closed = 2; +- } +- +- PyErr_SetString(OperationalError, PQerrorMessage(conn->pgconn)); +- return -1; +- } +- +- res = PQisBusy(conn->pgconn); +- +- Py_BLOCK_THREADS; +- conn_notifies_process(conn); +- conn_notice_process(conn); +- Py_UNBLOCK_THREADS; +- +- pthread_mutex_unlock(&(conn->lock)); +- Py_END_ALLOW_THREADS; +- +- return res; +-} +- +-/* pq_is_busy_locked - equivalent to pq_is_busy but we already have the lock +- * +- * The function should be called with the lock and holding the GIL. +- */ +- +-int +-pq_is_busy_locked(connectionObject *conn) +-{ +- Dprintf("pq_is_busy_locked: consuming input"); +- +- if (PQconsumeInput(conn->pgconn) == 0) { +- Dprintf("pq_is_busy_locked: PQconsumeInput() failed"); +- +- /* if the libpq says pgconn is lost, close the py conn */ +- if (CONNECTION_BAD == PQstatus(conn->pgconn)) { +- conn->closed = 2; +- } +- +- PyErr_SetString(OperationalError, PQerrorMessage(conn->pgconn)); +- return -1; +- } +- +- /* notices and notifies will be processed at the end of the loop we are in +- * (async reading) by pq_fetch. */ +- +- return PQisBusy(conn->pgconn); +-} +- + /* pq_flush - flush output and return connection status + + a status of 1 means that a some data is still pending to be flushed, while a +@@ -1094,6 +1020,8 @@ + Dprintf("pq_send_query: sending ASYNC query:"); + Dprintf(" %-.200s", query); + ++ CLEARPGRES(conn->pgres); ++ + if (0 == (rv = PQsendQuery(conn->pgconn, query))) { + Dprintf("pq_send_query: error: %s", PQerrorMessage(conn->pgconn)); + } +@@ -1998,3 +1926,90 @@ + + return ex; + } ++/* pq_get_result_async - read an available result without blocking. ++ * ++ * Return 0 if the result is ready, 1 if it will block, -1 on error. ++ * The last result will be returned in pgres. ++ * ++ * The function should be called with the lock and holding the GIL. ++ */ ++ ++RAISES_NEG int ++pq_get_result_async(connectionObject *conn) ++{ ++ int rv = -1; ++ ++ Dprintf("pq_get_result_async: calling PQconsumeInput()"); ++ if (PQconsumeInput(conn->pgconn) == 0) { ++ Dprintf("pq_get_result_async: PQconsumeInput() failed"); ++ ++ /* if the libpq says pgconn is lost, close the py conn */ ++ if (CONNECTION_BAD == PQstatus(conn->pgconn)) { ++ conn->closed = 2; ++ } ++ ++ PyErr_SetString(OperationalError, PQerrorMessage(conn->pgconn)); ++ goto exit; ++ } ++ ++ conn_notifies_process(conn); ++ conn_notice_process(conn); ++ ++ for (;;) { ++ int busy; ++ PGresult *res; ++ ExecStatusType status; ++ ++ Dprintf("pq_get_result_async: calling PQisBusy()"); ++ busy = PQisBusy(conn->pgconn); ++ ++ if (busy) { ++ /* try later */ ++ Dprintf("pq_get_result_async: PQisBusy() = 1"); ++ rv = 1; ++ goto exit; ++ } ++ ++ if (!(res = PQgetResult(conn->pgconn))) { ++ Dprintf("pq_get_result_async: got no result"); ++ /* the result is ready: it was the previously read one */ ++ rv = 0; ++ goto exit; ++ } ++ ++ status = PQresultStatus(res); ++ Dprintf("pq_get_result_async: got result %s", PQresStatus(status)); ++ ++ /* Store the result outside because we want to return the last non-null ++ * one and we may have to do it across poll calls. However if there is ++ * an error in the stream of results we want to handle the *first* ++ * error. So don't clobber it with the following ones. */ ++ if (conn->pgres && PQresultStatus(conn->pgres) == PGRES_FATAL_ERROR) { ++ Dprintf("previous pgres is error: discarding"); ++ PQclear(res); ++ } ++ else { ++ PQclear(conn->pgres); ++ conn->pgres = res; ++ } ++ ++ switch (status) { ++ case PGRES_COPY_OUT: ++ case PGRES_COPY_IN: ++ case PGRES_COPY_BOTH: ++ /* After entering copy mode, libpq will make a phony ++ * PGresult for us every time we query for it, so we need to ++ * break out of this endless loop. */ ++ rv = 0; ++ goto exit; ++ ++ default: ++ /* keep on reading to check if there are other results or ++ * we have finished. */ ++ continue; ++ } ++ } ++ ++exit: ++ return rv; ++} +diff -ur psycopg2-2.7.5/psycopg/pqpath.h psycopg2-2.7.5_patched/psycopg/pqpath.h +--- psycopg2-2.7.5/psycopg/pqpath.h 2018-06-17 18:07:41.000000000 +0200 ++++ psycopg2-2.7.5_patched/psycopg/pqpath.h 2023-07-03 12:38:19.000000000 +0200 +@@ -59,9 +59,8 @@ + const char *cmd, const char *tid, + PGresult **pgres, char **error, + PyThreadState **tstate); +-HIDDEN int pq_is_busy(connectionObject *conn); +-HIDDEN int pq_is_busy_locked(connectionObject *conn); + HIDDEN int pq_flush(connectionObject *conn); ++RAISES_NEG HIDDEN int pq_get_result_async(connectionObject *conn); + HIDDEN void pq_clear_async(connectionObject *conn); + RAISES_NEG HIDDEN int pq_set_non_blocking(connectionObject *conn, int arg); + +diff -ur psycopg2-2.7.5/tests/test_async.py psycopg2-2.7.5_patched/tests/test_async.py +--- psycopg2-2.7.5/tests/test_async.py 2018-06-17 18:07:41.000000000 +0200 ++++ psycopg2-2.7.5_patched/tests/test_async.py 2023-06-27 16:18:11.000000000 +0200 +@@ -99,7 +99,6 @@ + self.assertEquals(cur.fetchone()[0], "a") + + @slow +- @skip_before_postgres(8, 2) + def test_async_callproc(self): + cur = self.conn.cursor() + cur.callproc("pg_sleep", (0.1, )) +@@ -406,6 +405,15 @@ + cur.execute("delete from table1") + self.wait(cur) + ++ def test_stop_on_first_error(self): ++ cur = self.conn.cursor() ++ cur.execute("select 1; select x; select 1/0; select 2") ++ self.assertRaises(psycopg2.ProgrammingError, self.wait, cur) ++ ++ cur.execute("select 1") ++ self.wait(cur) ++ self.assertEqual(cur.fetchone(), (1,)) ++ + def test_error_two_cursors(self): + cur = self.conn.cursor() + cur2 = self.conn.cursor() +@@ -450,6 +458,36 @@ + else: + self.fail("no exception raised") + ++ @slow ++ def test_non_block_after_notification(self): ++ from select import select ++ ++ cur = self.conn.cursor() ++ cur.execute(""" ++ select 1; ++ do $$ ++ begin ++ raise notice 'hello'; ++ end ++ $$ language plpgsql; ++ select pg_sleep(1); ++ """) ++ ++ polls = 0 ++ while True: ++ state = self.conn.poll() ++ if state == psycopg2.extensions.POLL_OK: ++ break ++ elif state == psycopg2.extensions.POLL_READ: ++ select([self.conn], [], [], 0.1) ++ elif state == psycopg2.extensions.POLL_WRITE: ++ select([], [self.conn], [], 0.1) ++ else: ++ raise Exception("Unexpected result from poll: %r", state) ++ polls += 1 ++ ++ self.assert_(polls >= 8, polls) ++ + + def test_suite(): + return unittest.TestLoader().loadTestsFromName(__name__) +diff -ur psycopg2-2.7.5/tests/test_green.py psycopg2-2.7.5_patched/tests/test_green.py +--- psycopg2-2.7.5/tests/test_green.py 2018-06-17 18:07:41.000000000 +0200 ++++ psycopg2-2.7.5_patched/tests/test_green.py 2023-06-27 16:57:21.000000000 +0200 +@@ -22,12 +22,14 @@ + # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + # License for more details. + ++import select + import unittest + import psycopg2 + import psycopg2.extensions + import psycopg2.extras + + from testutils import ConnectingTestCase, slow ++from psycopg2.extensions import POLL_OK, POLL_READ, POLL_WRITE + + + class ConnectionStub(object): +@@ -55,10 +57,10 @@ + ConnectingTestCase.tearDown(self) + psycopg2.extensions.set_wait_callback(self._cb) + +- def set_stub_wait_callback(self, conn): ++ def set_stub_wait_callback(self, conn, cb=None): + stub = ConnectionStub(conn) + psycopg2.extensions.set_wait_callback( +- lambda conn: psycopg2.extras.wait_select(stub)) ++ lambda conn: (cb or psycopg2.extras.wait_select)(stub)) + return stub + + @slow +@@ -111,6 +113,35 @@ + curs.execute("select 1") + self.assertEqual(curs.fetchone()[0], 1) + ++ @slow ++ def test_non_block_after_notification(self): ++ def wait(conn): ++ while 1: ++ state = conn.poll() ++ if state == POLL_OK: ++ break ++ elif state == POLL_READ: ++ select.select([conn.fileno()], [], [], 0.1) ++ elif state == POLL_WRITE: ++ select.select([], [conn.fileno()], [], 0.1) ++ else: ++ raise conn.OperationalError("bad state from poll: %s" % state) ++ ++ stub = self.set_stub_wait_callback(self.conn, wait) ++ cur = self.conn.cursor() ++ cur.execute(""" ++ select 1; ++ do $$ ++ begin ++ raise notice 'hello'; ++ end ++ $$ language plpgsql; ++ select pg_sleep(1); ++ """) ++ ++ polls = stub.polls.count(POLL_READ) ++ self.assert_(polls > 8, polls) ++ + + class CallbackErrorTestCase(ConnectingTestCase): + def setUp(self): diff --git a/SPECS/python-psycopg2.spec b/SPECS/python-psycopg2.spec new file mode 100644 index 0000000..00a33a0 --- /dev/null +++ b/SPECS/python-psycopg2.spec @@ -0,0 +1,607 @@ +%bcond_with python36_module + +%if 0%{?fedora} +%bcond_without python2 +%bcond_without python3 +%else +%bcond_with python2 +%bcond_without python3 +%endif + +%bcond_without check + +%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 python2-debug} \\\ + %{?with_python3:python3.6 python3.6-debug} + +%{!?with_python2:%{!?with_python3:%{error:one python version eneeded}}} + +# 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-%{srcname} +Version: 2.7.5 +Release: 8%{?dist} +# The exceptions allow linking to OpenSSL and PostgreSQL's libpq +License: LGPLv3+ with exceptions +Group: Applications/Databases +Url: http://www.psycopg.org/psycopg/ + +Source0: http://www.psycopg.org/psycopg/tarballs/PSYCOPG-2-7/psycopg2-%{version}.tar.gz + +# Related to https://bugzilla.redhat.com/show_bug.cgi?id=1909674 +Patch1: psycopg2_get_result_async.patch + +%{?with_python2:BuildRequires: python2-debug python2-devel} +%if %{with python36_module} +%{?with_python3:BuildRequires: python36-debug python36-devel} +%{?with_python3:BuildRequires: python36-rpm-macros} +%else +%{?with_python3:BuildRequires: python3-debug python3-devel} +%endif + +BuildRequires: gcc +BuildRequires: pkgconfig(libpq) + +# For testsuite +%if %{with check} +BuildRequires: postgresql-test-rpm-macros +%endif + +Conflicts: python-psycopg2-zope < %{version} + +%description +%{desc} + + +%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. + + +%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. + + +%if %{with python3} +%package -n python3-psycopg2 +Summary: %{sum} 3 +%{?python_provide:%python_provide python3-%{srcname}} + +%description -n python3-psycopg2 +%{desc} + + +%package -n python3-%{srcname}-tests +Summary: A testsuite for %sum 2 +Requires: python3-%srcname = %version-%release + +%description -n python3-%{srcname}-tests +%desc +This sub-package delivers set of tests for the adapter. + + +%package -n python3-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: python3-psycopg2 = %{version}-%{release} + +%description -n python3-%{srcname}-debug +This is a build of the psycopg PostgreSQL database adapter for the debug +build of Python 3. +%endif # python3 + + +%package doc +Summary: Documentation for psycopg python PostgreSQL database adapter +Group: Documentation +%{?with_python2:Provides: python2-%{srcname}-doc = %{version}-%{release}} +%{?with_python3:Provides: python3-%{srcname}-doc = %{version}-%{release}} + +%description doc +Documentation and example files for the psycopg python PostgreSQL +database adapter. + + +%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 +Group: Applications/Databases +Requires: %{name} = %{version}-%{release} +Requires: zope + +%description zope +Zope Database Adapter for PostgreSQL, called ZPsycopgDA +%endif + + +%prep +%autosetup -p1 -n psycopg2-%{version} + + +%build +for python in %{python_runtimes} ; do + $python setup.py build +done + +# Fix for wrong-file-end-of-line-encoding problem; upstream also must fix this. +for i in `find doc -iname "*.html"`; do sed -i 's/\r//' $i; done +for i in `find doc -iname "*.css"`; do sed -i 's/\r//' $i; done + +# Get rid of a "hidden" file that rpmlint complains about +rm -f doc/html/.buildinfo + +# We can not build docs now: +# https://www.postgresql.org/message-id/2741387.dvL6Cb0VMB@nb.usersys.redhat.com +# make -C doc/src html + + +%check +%if %{with check} +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="from psycopg2 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 # check + + +%install +for python in %{python_runtimes} ; do + $python setup.py install --no-compile --root %{buildroot} +done + +%if %zope +install -d %{buildroot}%{ZPsycopgDAdir} +cp -pr ZPsycopgDA/* %{buildroot}%{ZPsycopgDAdir} +%endif + +# This test is skipped on 3.7 and has a syntax error so brp-python-bytecompile would choke on it +%{?with_python3:rm -r %{buildroot}%{python3_sitearch}/%{srcname}/tests/test_async_keyword.py} + +%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 + + +%files -n python2-%{srcname}-debug +%license LICENSE +%{python2_sitearch}/psycopg2/_psycopg_d.so +%endif # python2 + + +%if %{with python3} +%files -n python3-psycopg2 +%license LICENSE +%doc AUTHORS NEWS README.rst +%dir %{python3_sitearch}/psycopg2 +%{python3_sitearch}/psycopg2/*.py +%{python3_sitearch}/psycopg2/_psycopg.cpython-3?m*.so +%dir %{python3_sitearch}/psycopg2/__pycache__ +%{python3_sitearch}/psycopg2/__pycache__/*.py{c,o} +%{python3_sitearch}/psycopg2-%{version}-py3*.egg-info + + +%files -n python3-%{srcname}-tests +%{python3_sitearch}/psycopg2/tests + + +%files -n python3-psycopg2-debug +%license LICENSE +%{python3_sitearch}/psycopg2/_psycopg.cpython-3?dm*.so +%endif # python3 + + +%files doc +%license LICENSE +%doc doc examples/ + + +%if %zope +%files zope +%license LICENSE +%dir %{ZPsycopgDAdir} +%{ZPsycopgDAdir}/*.py +%{ZPsycopgDAdir}/*.pyo +%{ZPsycopgDAdir}/*.pyc +%{ZPsycopgDAdir}/dtml/* +%{ZPsycopgDAdir}/icons/* +%endif + + +%changelog +* Wed Apr 03 2024 MSVSphere Packaging Team - 2.7.5-8 +- Rebuilt for MSVSphere 8.10 beta + +* Wed Jun 28 2023 Filip Janus - 2.7.5-8 +- Added patch for support pq_get_result_async() +- Resolves: #1909674 + +* Thu Apr 25 2019 Tomas Orsava - 2.7.5-7 +- Bumping due to problems with modular RPM upgrade path +- Resolves: rhbz#1695587 + +* Wed Sep 26 2018 Tomas Orsava - 2.7.5-6 +- Use the fully versioned binaries during build +- Related: rhbz#1619153 + +* Mon Sep 17 2018 Tomas Orsava - 2.7.5-5 +- Require python2-psycopg2 instead of python-psycopg2 from the + python2-psycopg2-debug subpackage +- Resolves: rhbz#1628242 + +* Thu Aug 02 2018 Pavel Raiskup - 2.7.5-4 +- re-enable testsuite + +* Wed Aug 01 2018 Lumír Balhar - 2.7.5-3 +- Disable failing tests + +* Wed Jul 18 2018 Tomas Orsava - 2.7.5-2 +- BuildRequire also python36-rpm-macros as part of the python36 module build + +* Tue Jul 17 2018 Pavel Raiskup - 2.7.5-1 +- sync with fedora rawhide + +* Tue May 01 2018 Tomas Orsava - 2.7.4-5 +- Let the doc subpackage be standalone installable + +* Wed Apr 25 2018 Tomas Orsava - 2.7.4-4 +- Make requires on python36-devel/debug dependant on a python36_module bcond + +* Mon Apr 23 2018 Tomas Orsava - 2.7.4-3 +- Revert switching Python 3 subpackages to the python3X- prefix +- Switch only the requires for python3-devel/debug to the python36-prefix: + the rest of the packages in the python36 collection will have the python3 + prefix to be unified with the Python 3 packages for Platform-Python + +* Wed Apr 18 2018 Tomas Orsava - 2.7.4-2 +- Switch the Python 3 subpackages to the python3X- prefix using + the %{python3_pkgversion} macro + +* Mon Feb 12 2018 Pavel Raiskup - 2.7.4-1 +- rebase to latest upstream release, per release notes: + http://initd.org/psycopg/articles/2018/02/08/psycopg-274-released/ + +* Fri Feb 09 2018 Fedora Release Engineering - 2.7.3.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Thu Dec 14 2017 Pavel Raiskup - 2.7.3.2-2 +- treat python3/python2 equally + +* Wed Oct 25 2017 Pavel Raiskup - 2.7.3.2-1 +- update to 2.7.3.2, per release notes: + http://initd.org/psycopg/articles/2017/10/24/psycopg-2732-released/ + +* Mon Aug 28 2017 Pavel Raiskup - 2.7.3.1-1 +- http://initd.org/psycopg/articles/2017/08/26/psycopg-2731-released/ + +* Sun Aug 13 2017 Pavel Raiskup - 2.7.3-1 +- rebase to latest upstream release, per release notes: + http://initd.org/psycopg/articles/2017/07/24/psycopg-273-released/ + +* Thu Aug 03 2017 Fedora Release Engineering - 2.7.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Thu Jul 27 2017 Fedora Release Engineering - 2.7.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Sun Jul 23 2017 Pavel Raiskup - 2.7.2-1 +- rebase to latest upstream release, per release notes: + http://initd.org/psycopg/articles/2017/07/22/psycopg-272-released/ + +* Mon Mar 13 2017 Pavel Raiskup - 2.7.1-1 +- rebase to latest upstream release, per release notes: + http://initd.org/psycopg/articles/2017/03/01/psycopg-271-released/ +- fix testsuite + +* Thu Mar 02 2017 Pavel Raiskup - 2.7-1 +- rebase to latest upstream release, per release notes: + http://initd.org/psycopg/articles/2017/03/01/psycopg-27-released/ +- enable testsuite during build, and package it + +* Sat Feb 11 2017 Fedora Release Engineering - 2.6.2-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Fri Dec 09 2016 Charalampos Stratakis - 2.6.2-3 +- Rebuild for Python 3.6 + +* Tue Jul 19 2016 Fedora Release Engineering - 2.6.2-2 +- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages + +* Thu Jul 07 2016 Pavel Raiskup - 2.6.2-1 +- rebase (rhbz#1353545), per release notes + http://initd.org/psycopg/articles/2016/07/07/psycopg-262-released/ + +* Sun May 29 2016 Pavel Raiskup - 2.6.1-6 +- provide python2-psycopg2 (rhbz#1306025) +- cleanup obsoleted packaging stuff + +* Thu Feb 04 2016 Fedora Release Engineering - 2.6.1-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Sun Nov 15 2015 Pavel Raiskup - 2.6.1-4 +- again bump for new Python 3.5, not build previously? +- fix rpmlint issues +- no pyo files with python 3.5 + +* Tue Nov 10 2015 Fedora Release Engineering +- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5 + +* Thu Jun 18 2015 Fedora Release Engineering - 2.6.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Mon Jun 15 2015 Jozef Mlich 2.6.1-1 +- Update to 2.6.1 + +* Mon Feb 9 2015 Devrim Gündüz 2.6-1 +- Update to 2.6, per changes described at: + http://www.psycopg.org/psycopg/articles/2015/02/09/psycopg-26-and-255-released/ + +* Tue Jan 13 2015 Devrim Gündüz 2.5.4-1 +- Update to 2.5.4, per changes described at: + http://www.psycopg.org/psycopg/articles/2014/08/30/psycopg-254-released + +* Sun Aug 17 2014 Fedora Release Engineering - 2.5.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Fri Jul 04 2014 Pavel Raiskup - 2.5.3-1 +- rebase to most recent upstream version, per release notes: + http://www.psycopg.org/psycopg/articles/2014/05/13/psycopg-253-released/ + +* Sat Jun 07 2014 Fedora Release Engineering - 2.5.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Tue May 13 2014 Bohuslav Kabrda - 2.5.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Changes/Python_3.4 + +* Tue Jan 7 2014 Devrim Gündüz 2.5.2-1 +- Update to 2.5.2, per changes described at: + http://www.psycopg.org/psycopg/articles/2014/01/07/psycopg-252-released + +* Sun Aug 04 2013 Fedora Release Engineering - 2.5.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Sun Jul 07 2013 Pavel Raiskup - 2.5.1-1 +- rebase to 2.5.1 + +* Thu May 16 2013 Devrim Gündüz 2.5-1 +- Update to 2.5, per changes described at: + http://www.psycopg.org/psycopg/articles/2013/04/07/psycopg-25-released/ + +* Thu Feb 14 2013 Fedora Release Engineering - 2.4.5-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Sat Aug 04 2012 David Malcolm - 2.4.5-6 +- rebuild for https://fedoraproject.org/wiki/Features/Python_3.3 + +* Fri Aug 3 2012 David Malcolm - 2.4.5-5 +- generalize python 3 fileglobbing to work with both Python 3.2 and 3.3 + +* Fri Aug 3 2012 David Malcolm - 2.4.5-4 +- replace "python3.2dmu" with "python3-debug"; with_python3 fixes + +* Fri Aug 3 2012 David Malcolm - 2.4.5-3 +- add with_python3 conditional + +* Sat Jul 21 2012 Fedora Release Engineering - 2.4.5-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Sat Apr 7 2012 Tom Lane 2.4.5-1 +- Update to 2.4.5 + +* Thu Feb 2 2012 Tom Lane 2.4.4-1 +- Update to 2.4.4 +- More specfile neatnik-ism + +* Sat Jan 14 2012 Fedora Release Engineering - 2.4.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Tue Nov 29 2011 Tom Lane 2.4.2-2 +- Fix mistaken %%dir marking on python3 files, per Dan Horak + +* Sat Jun 18 2011 Tom Lane 2.4.2-1 +- Update to 2.4.2 +Related: #711095 +- Some neatnik specfile cleanups + +* Thu Feb 10 2011 David Malcolm - 2.4-0.beta2 +- 2.4.0-beta2 +- add python 2 debug, python3 (optimized) and python3-debug subpackages + +* Tue Feb 08 2011 Fedora Release Engineering - 2.3.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Wed Dec 29 2010 Tom Lane 2.3.2-1 +- Update to 2.3.2 +- Clean up a few rpmlint warnings + +* Fri Dec 03 2010 Jason L Tibbitts III - 2.2.2-3 +- Fix incorrect (and invalid) License: tag. + +* Thu Jul 22 2010 David Malcolm - 2.2.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild + +* Tue Jul 20 2010 Devrim GUNDUZ - 2.2.2-1 +- Update to 2.2.2 + +* Tue May 18 2010 Devrim GUNDUZ - 2.2.1-1 +- Update to 2.2.1 +- Improve description for 2.2 features. +- Changelog for 2.2.0 is: + http://initd.org/pub/software/psycopg/ChangeLog-2.2 + +* Wed Mar 17 2010 Devrim GUNDUZ - 2.0.14-1 +- Update to 2.0.14 +- Update license (upstream switched to LGPL3) + +* Sun Jan 24 2010 Tom Lane 2.0.13-2 +- Fix rpmlint complaints: remove unneeded explicit Requires:, use Conflicts: + instead of bogus Obsoletes: to indicate lack of zope subpackage + +* Sun Oct 18 2009 Devrim GUNDUZ - 2.0.13-1 +- Update to 2.0.13 + +* Fri Aug 14 2009 Devrim GUNDUZ - 2.0.12-1 +- Update to 2.0.12 + +* Sun Jul 26 2009 Fedora Release Engineering - 2.0.11-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Tue May 19 2009 Devrim GUNDUZ - 2.0.11-1 +- Update to 2.0.11 + +* Tue Apr 21 2009 Devrim GUNDUZ - 2.0.10-1 +- Update to 2.0.10 + +* Fri Mar 20 2009 Devrim GUNDUZ - 2.0.9-1 +- Update to 2.0.9 + +* Thu Feb 26 2009 Fedora Release Engineering - 2.0.8-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Thu Dec 04 2008 Ignacio Vazquez-Abrams - 2.0.8-2 +- Rebuild for Python 2.6 + +* Sat Nov 29 2008 Devrim GUNDUZ - 2.0.8-1 +- Update to 2.0.8 + +* Sat Nov 29 2008 Devrim GUNDUZ - 2.0.8-1 +- Update to 2.0.8 + +* Sat Nov 29 2008 Ignacio Vazquez-Abrams - 2.0.7-3 +- Rebuild for Python 2.6 + +* Thu May 29 2008 Todd Zullinger - 2.0.7-2 +- fix license tags + +* Wed Apr 30 2008 Devrim GUNDUZ 2.0.7-1 +- Update to 2.0.7 + +* Mon Feb 18 2008 Fedora Release Engineering - 2.0.6-4.1 +- Autorebuild for GCC 4.3 + +* Mon Jan 21 2008 - Devrim GUNDUZ 2.0.6-3.1 +- Rebuilt against PostgreSQL 8.3 + +* Thu Jan 3 2008 - Devrim GUNDUZ 2.0.6-3 +- Rebuild for rawhide changes + +* Tue Aug 28 2007 Fedora Release Engineering - 2.0.6-2 +- Rebuild for selinux ppc32 issue. + +* Fri Jun 15 2007 - Devrim GUNDUZ 2.0.6-1 +- Update to 2.0.6 + +* Thu Apr 26 2007 - Devrim GUNDUZ 2.0.5.1-8 +- Disabled zope package temporarily. + +* Wed Dec 6 2006 - Devrim GUNDUZ 2.0.5.1-7 +- Rebuilt + +* Wed Dec 6 2006 - Devrim GUNDUZ 2.0.5.1-5 +- Bumped up spec version + +* Wed Dec 6 2006 - Devrim GUNDUZ 2.0.5.1-4 +- Rebuilt for PostgreSQL 8.2.0 + +* Mon Sep 11 2006 - Devrim GUNDUZ 2.0.5.1-3 +- Rebuilt + +* Wed Sep 6 2006 - Devrim GUNDUZ 2.0.5.1-2 +- Remove ghost'ing, per Python Packaging Guidelines + +* Mon Sep 4 2006 - Devrim GUNDUZ 2.0.5.1-1 +- Update to 2.0.5.1 + +* Sun Aug 6 2006 - Devrim GUNDUZ 2.0.3-3 +- Fixed zope package dependencies and macro definition, per bugzilla review (#199784) +- Fixed zope package directory ownership, per bugzilla review (#199784) +- Fixed cp usage for zope subpackage, per bugzilla review (#199784) + +* Mon Jul 31 2006 - Devrim GUNDUZ 2.0.3-2 +- Fixed 64 bit builds +- Fixed license +- Added Zope subpackage +- Fixed typo in doc description +- Added macro for zope subpackage dir + +* Mon Jul 31 2006 - Devrim GUNDUZ 2.0.3-1 +- Update to 2.0.3 +- Fixed spec file, per bugzilla review (#199784) + +* Sat Jul 22 2006 - Devrim GUNDUZ 2.0.2-3 +- Removed python dependency, per bugzilla review. (#199784) +- Changed doc package group, per bugzilla review. (#199784) +- Replaced dos2unix with sed, per guidelines and bugzilla review (#199784) +- Fix changelog dates + +* Sat Jul 22 2006 - Devrim GUNDUZ 2.0.2-2 +- Added dos2unix to buildrequires +- removed python related part from package name + +* Fri Jul 21 2006 - Devrim GUNDUZ 2.0.2-1 +- Fix rpmlint errors, including dos2unix solution +- Re-engineered spec file + +* Mon Jan 23 2006 - Devrim GUNDUZ +- First 2.0.X build + +* Mon Jan 23 2006 - Devrim GUNDUZ +- Update to 1.2.21 + +* Tue Dec 06 2005 - Devrim GUNDUZ +- Initial release for 1.1.20