psycopg / psycopg2

PostgreSQL database adapter for the Python programming language
https://www.psycopg.org/
Other
3.31k stars 502 forks source link

Psycopg2 doesn't install on Python 3.13 alpha #1692

Open junepark678 opened 4 months ago

junepark678 commented 4 months ago

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:

Please complete the following information:

hroncok commented 4 months ago

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

befeleme commented 4 months ago

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

dvarrazzo commented 4 months ago

Can you provide a MR with the function renamed, and a change to the tests to accept both the results?

Thank you very much 🙂

rouilj commented 1 month ago

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
dvarrazzo commented 1 month ago

@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 commented 1 month ago

@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
edgarrmondragon commented 1 month ago

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.

dvarrazzo commented 1 month ago

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: