GeezerVison is showing github.com — Py_GetConstant compatibility breaking numpy build · Issue #89 · python/pythoncapi-compat
Py_GetConstant compatibility breaking numpy build #89
Description
Which looks like a collaboration of python/cpython#116883 and #87
FAILED: numpy/_core/_multiarray_umath.cpython-313-x86_64-linux-gnu.so.p/meson-generated_scalartypes.c.o
ccache cc -Inumpy/_core/_multiarray_umath.cpython-313-x86_64-linux-gnu.so.p -Inumpy/_core -I../numpy/_core -Inumpy/_core/include -I../numpy/_core/include -I../numpy/_core/src/common -I../numpy/_core/src/multiarray -I../numpy/_core/src/npymath -I../numpy/_core/src/umath -I/opt/intel/oneapi/mkl/latest/include -I/home/tcaswell/.pybuild/py313/include/python3.13 -I/tmp/build-via-sdist-qfvwz43e/numpy-2.1.0.dev0/.mesonpy-jctwrujm/meson_cpu -fvisibility=hidden -fdiagnostics-color=always -DNDEBUG -Wall -Winvalid-pch -std=c11 -O3 -fno-strict-aliasing -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -mf16c -mfma -mavx2 -DNPY_HAVE_SSE2 -DNPY_HAVE_SSE -DNPY_HAVE_SSE3 -DNPY_HAVE_SSSE3 -DNPY_HAVE_SSE41 -DNPY_HAVE_POPCNT -DNPY_HAVE_SSE42 -DNPY_HAVE_AVX -DNPY_HAVE_F16C -DNPY_HAVE_FMA3 -DNPY_HAVE_AVX2 -Wall -O2 -pipe -fomit-frame-pointer -fno-strict-aliasing -Wmaybe-uninitialized -Wdeprecated-declarations -Wimplicit-function-declaration -march=native -DCYTHON_FAST_THREAD_STATE=0 -fPIC -DHAVE_CBLAS -DNPY_INTERNAL_BUILD -DHAVE_NPY_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -MD -MQ numpy/_core/_multiarray_umath.cpython-313-x86_64-linux-gnu.so.p/meson-generated_scalartypes.c.o -MF numpy/_core/_multiarray_umath.cpython-313-x86_64-linux-gnu.so.p/meson-generated_scalartypes.c.o.d -o numpy/_core/_multiarray_umath.cpython-313-x86_64-linux-gnu.so.p/meson-generated_scalartypes.c.o -c numpy/_core/_multiarray_umath.cpython-313-x86_64-linux-gnu.so.p/scalartypes.c
In file included from ../numpy/_core/src/common/npy_pycompat.h:5,
from ../numpy/_core/src/multiarray/scalartypes.c.src:16:
../numpy/_core/src/common/pythoncapi-compat/pythoncapi_compat.h:1227:25: error: static declaration of ‘Py_GetConstant’ follows non-static declaration
1227 | static inline PyObject* Py_GetConstant(unsigned int constant_id)
| ^~~~~~~~~~~~~~
In file included from /home/tcaswell/.pybuild/py313/include/python3.13/Python.h:58,
from ../numpy/_core/src/multiarray/scalartypes.c.src:3:
/home/tcaswell/.pybuild/py313/include/python3.13/object.h:1088:23: note: previous declaration of ‘Py_GetConstant’ with type ‘PyObject *(unsigned int)’ {aka ‘struct _object *(unsigned int)’}
1088 | PyAPI_FUNC(PyObject*) Py_GetConstant(unsigned int constant_id);
| ^~~~~~~~~~~~~~
../numpy/_core/src/common/pythoncapi-compat/pythoncapi_compat.h:1280:25: error: static declaration of ‘Py_GetConstantBorrowed’ follows non-static declaration
1280 | static inline PyObject* Py_GetConstantBorrowed(unsigned int constant_id)
| ^~~~~~~~~~~~~~~~~~~~~~
/home/tcaswell/.pybuild/py313/include/python3.13/object.h:1089:23: note: previous declaration of ‘Py_GetConstantBorrowed’ with type ‘PyObject *(unsigned int)’ {aka ‘struct _object *(unsigned int)’}
1089 | PyAPI_FUNC(PyObject*) Py_GetConstantBorrowed(unsigned int constant_id);
| ^~~~~~~~~~~~~~~~~~~~~~
[209/412] C
but I have not any debugging other than to try building with 5a76d1be8ef371b75ca65166726923c249b5f615 (with c4bf58a14f162557038a1535ca22c52b49d81d7b cherry-picked on) for CPython (which worked) and pushing the numpy's submodule of this repo back one commit (which worked).
It does not appear that numpy otherwise uses these symbols, but I have not tracked down if this is a "numpy is using it wrong" problem or this project is confliting with cpython problem.
attn @rgommers
Activity
vstinner commented on Apr 4, 2024
Hi, which Python 3.13 version are you testing exactly? Are you testing a Python 3.13 release or the main development branch?
tacaswell commented on Apr 4, 2024
vstinner commented on Apr 4, 2024
Why are you testing the main branch instead of 3.13 alpha releases?
pythoncapi-compat.h doesn't work well with the main branch (between alpha0 and beta1), while C API functions are being added. It's uneasy to check if a function is available or not, since Include/patchlevel.h macros are the same between 3.13.0a5 release and 3.13.0a5+ (current main branch), except of the PY_VERSION constant which is a string (cannot be used in the preprocessor).
vstinner commented on Apr 4, 2024
If you embed a copy of pythoncapi-compat.h, you can just remove Py_GetConstant() from your copy for now, until Python 3.13.0a6 is released (or until a solution is found in pythoncapi-compat.h).
Py_GetConstant() is only needed in pythoncapi-compat.h if you plan to use Py_GetConstant() with Python 3.12 and older.
added a commit that references this issue
on Apr 4, 2024gh-89: Fix Py_GetConstant() for Python 3.13.0a5+
vstinner commented on Apr 4, 2024
Ok, I fixed the issue with the change commit 68aad45. Thanks for the bug report @tacaswell.
These issues should not happen with regular 3.x.y minor and bugfix releases, only with alpha releases.
I usually attempt to avoid them for people who are following closely the main branch.
Reacted by Thomas A Caswell
tacaswell commented on Apr 4, 2024
Reacted by Victor Stinner
Reacted by Miro Hrončok
Reacted by Victor Stinner and Erlend E. Aasland
Metadata
Metadata
Development
No branches or pull requestsIssue actions