psycopg2
psycopg2 copied to clipboard
Psycopg2 doesn't install on Python 3.13 alpha
This is a bug tracker If you have a question, such has "how do you do X with Python/PostgreSQL/psycopg2" please write to the mailing list or open a question instead.
Before opening this ticket, please confirm that:
- [X] I am running the latest version of pip, i.e. typing
pip --versionyou get this version. - [X] I have read the installation documentation and the frequently asked questions
- [X] If install failed, I typed
pg_configon the command line and I obtained an output instead of an error.
Please complete the following information:
- OS: Linux (6.8.5-zen1-1-zen) on Arch Linux
- Psycopg version: 2.9.9
- Python version: 3.13.0a6+ (heads/main:6dc661bc9f)
- PostgreSQL version: 16.2
- pip version: 24.0
https://github.com/psycopg/psycopg2/blob/a971c11d5038333f08821ef452ce1237a22cdb0e/psycopg/utils.c#L395-L397
This function was made public and was renamed to PyInterpreterState_Get in Python 3.13.0a1+ in https://github.com/python/cpython/pull/106321
And after a rename of the function, this is the test run:
======================================================================
FAIL: test_cidr_adapt (tests.test_ipaddress.NetworkingTestCase.test_cidr_adapt)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/builddir/build/BUILD/psycopg2-2.9.9/tests/test_ipaddress.py", line 112, in test_cidr_adapt
self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128')
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '::ffff:1.2.3.0/128' != '::ffff:102:300/128'
- ::ffff:1.2.3.0/128
? ^ ^ ^
+ ::ffff:102:300/128
? ^ ^ ^
======================================================================
FAIL: test_inet_adapt (tests.test_ipaddress.NetworkingTestCase.test_inet_adapt)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/builddir/build/BUILD/psycopg2-2.9.9/tests/test_ipaddress.py", line 71, in test_inet_adapt
self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128')
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '::ffff:1.2.3.0/128' != '::ffff:102:300/128'
- ::ffff:1.2.3.0/128
? ^ ^ ^
+ ::ffff:102:300/128
? ^ ^ ^
Apparently, the textual representation of addresses has changed: https://github.com/python/cpython/commit/f22bf8e3cf899896cf587099d29290cb43aa9724
Can you provide a MR with the function renamed, and a change to the tests to accept both the results?
Thank you very much 🙂
Any idea when 3.13 will be supported? I'm failing on 3.13b3. The expected release schedule calls for b4 this week and rc1 at the end of the month.
(t) root@6395f424f6b7:/tmp# python -V
Python 3.13.0b3
(t) root@6395f424f6b7:/tmp# python -m pip install psycopg2
Collecting psycopg2
Downloading psycopg2-2.9.9.tar.gz (384 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 384.9/384.9 kB 2.3 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: psycopg2
Building wheel for psycopg2 (pyproject.toml) ... done
Created wheel for psycopg2: filename=psycopg2-2.9.9-cp313-cp313-linux_x86_64.whl size=520707 sha256=af5abb7a4e648707110e8a416f0097c11456157c7d7240de40517c99d902c6d0
Stored in directory: /root/.cache/pip/wheels/2a/2a/86/08f4d537c1f8ebeeb82497d4a665e0eea2934e03b5aed4518c
Successfully built psycopg2
Installing collected packages: psycopg2
Successfully installed psycopg2-2.9.9
[notice] A new release of pip is available: 24.1.1 -> 24.1.2
[notice] To update, run: pip install --upgrade pip
(t) root@6395f424f6b7:/tmp# python3
Python 3.13.0b3 (main, Jul 10 2024, 19:08:39) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
import psycopg2
File "/tmp/t/lib/python3.13/site-packages/psycopg2/__init__.py", line 51, in <module>
from psycopg2._psycopg import ( # noqa
...<10 lines>...
)
ImportError: /tmp/t/lib/python3.13/site-packages/psycopg2/_psycopg.cpython-313-x86_64-linux-gnu.so: undefined symbol: _PyInterpreterState_Get
@rouilj As I already told you on #1695, we are not planning to release beta packages on PyPI until the 3.13 is officially released.
I have merged 3.13 support to master. I tried to build sdist packages to push them at least on test.pypy.org but the build pipeline is completely bitrot and I am not able to fix it immediately.
If you can fix the build pipeline I can upload a test package on test pypi.
@rouilj As I already told you on #1695, we are not planning to release beta packages on PyPI until the 3.13 is officially released.
Thanks for the reminder. I had forgotten 8-(.
I have merged 3.13 support to master. I tried to build sdist packages to push them at least on test.pypy.org but the build pipeline is completely bitrot and I am not able to fix it immediately.
If you can fix the build pipeline I can upload a test package on test pypi.
I didn't realize that you only build for release/publication. I thought every commit got built (but not published).
I see the failure to push the build archive to the artifact store due to a name conflict. But the logs for the last successful build have expired and I can't see what has changed between this newest build and the last successful build. So I am afraid I am not of much help here.
I'll just tell the interested parties not to expect postgresql support on 3.13 until December at the earliest. With luck I won't have to change any code and just getting psycopg2 installed will allow things to work.
Thanks for your response to my (duplicate) question.
P.S. not sure if it will help but I have used action-tmate to allow me to access the CI container to try to figure out what broke in the build pipeline. I use something like this:
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
timeout-minutes: 10
with:
limit-access-to-actor: true
fwiw it looks like the workflow broke with the v4 upload/download artifact actions, which require unique artifact names. The fix for that should adding a suffix to the artifact name on the upload step, and a glob expression on the download step.
Yes, most definitely the upload workflow broke for the v4 passage. We had the same breakage in the psycopg 3 repository but someone was kind enough to provide an upgrade. So we have a good reference of something working, we will need to backport it here.
Everything else that is currently failing (macOS builds, windows builds) is currently working on psycopg 3 so we can do a work of backporting all the other solutions used there. They include:
- building windows packages on Github actions, if we cannot fix Appveyor
- building macOS ARM64 packages on Github actions (instead of Scaleway)
- adapting to newer versions of cibuildwheel
- building libpq with OpenSSL 3.x
Psycopg 2.9.10 released with Python 3.13 support.
Not for Windows yet because we need Appveyor to add support to 3.13: see https://github.com/psycopg/psycopg2/issues/1736