Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Psycopg2 doesn't install on Python 3.13 alpha #1692

Closed
3 tasks done
Tracked by #8618
junepark678 opened this issue Apr 16, 2024 · 9 comments
Closed
3 tasks done
Tracked by #8618

Psycopg2 doesn't install on Python 3.13 alpha #1692

junepark678 opened this issue Apr 16, 2024 · 9 comments

Comments

@junepark678
Copy link

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:

  • 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
@hroncok
Copy link
Contributor

hroncok commented Apr 23, 2024

psycopg2/psycopg/utils.c

Lines 395 to 397 in a971c11

#if PY_VERSION_HEX >= 0x03080000
/* tested with Python 3.8.0a2 */
return _PyInterpreterState_Get() == PyInterpreterState_Main();

This function was made public and was renamed to PyInterpreterState_Get in Python 3.13.0a1+ in python/cpython#106321

@befeleme
Copy link
Contributor

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: python/cpython@f22bf8e

@dvarrazzo
Copy link
Member

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
Copy link

rouilj commented Jul 14, 2024

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
Copy link
Member

@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
Copy link

rouilj commented Jul 14, 2024

@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
Copy link
Contributor

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
Copy link
Member

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

philipnbbc added a commit to bbc/rd-cloudfit-python-aiocypher that referenced this issue Oct 8, 2024
The Python package reports that up to Python 3.11 is supported.

See also psycopg/psycopg2#1692
philipnbbc added a commit to bbc/rd-cloudfit-python-aiocypher that referenced this issue Oct 8, 2024
The Python package reports that up to Python 3.12 is supported.

See also psycopg/psycopg2#1692
@dvarrazzo
Copy link
Member

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 #1736

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants