actions / setup-python

Set up your GitHub Actions workflow with a specific version of Python
MIT License
1.59k stars 505 forks source link

Psycopg2 install/build fails when imported python 3.13beta1 - cpython-313-x86_64-linux-gnu.so: undefined symbol: _PyInterpreterState_Get #864

Closed rouilj closed 1 month ago

rouilj commented 1 month ago

Description: In order to run psycopg2, I have to install it manually in the 3.13 tree. When I do this, it builds successfully with 3.13beta1 (the build failed with 3.13alpha6 see #848). But when importing psycopg2 I get:

  ImportError: /opt/hostedtoolcache/Python/3.13.0-beta.1/x64/lib/python3.13/site-packages/psycopg2/_psycopg.cpython-313-x86_64-linux-gnu.so: undefined symbol: _PyInterpreterState_Get

Action version:

actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d

Platform:

Runner type:

Tools version:

3.13beta1

Repro steps:

 pip install psycopg2
 python -c 'import psycopg2'

should cause the crash on import with:

ImportError: /opt/hostedtoolcache/Python/3.13.0-beta.1/x64/lib/python3.13/site-packages/psycopg2/_psycopg.cpython-313-x86_64-linux-gnu.so: undefined symbol: _PyInterpreterState_Get

Expected behavior:

No import error and the ability to use the package to connect to the running postgresql server.

Actual behavior:

Crash with import error:

ImportError: /opt/hostedtoolcache/Python/3.13.0-beta.1/x64/lib/python3.13/site-packages/psycopg2/_psycopg.cpython-313-x86_64-linux-gnu.so: undefined symbol: _PyInterpreterState_Get

You can see the run at:

https://github.com/roundup-tracker/roundup/actions/runs/9054459071/job/24874353963

for full details. The pip install psycopg2 is located under the section "Install python db libraries" and the import crash is under the section: "Test build roundup and install locale so lang tests work."

HarithaVattikuti commented 1 month ago

Hello @rouilj Thank you for creating this issue. We will investigate it and get back to you as soon as we have some feedback.

mayeut commented 1 month ago

this is an issue with psycopg2, not setup-python: https://github.com/psycopg/psycopg2/pull/1695

rouilj commented 1 month ago

this is an issue with psycopg2, not setup-python: psycopg/psycopg2#1695

Thanks for the pointer to that issue. It looks like that could be the problem.

The patch for psycopg/utils.c in that issue appears to change _PyInterpreterState_Get to PyInterpreterState_Get for 3.13. I'll close this for now as I have followed up on psycopg2's 1695. I'll re-open if it turns out that's not the fix.

Thanks.