Skip to content

Py_GetConstant compatibility breaking numpy build #89

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

Closed
tacaswell opened this issue Apr 4, 2024 · 6 comments
Closed

Py_GetConstant compatibility breaking numpy build #89

tacaswell opened this issue Apr 4, 2024 · 6 comments

Comments

@tacaswell
Copy link

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

@vstinner
Copy link
Member

vstinner commented 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
Copy link
Author

main branch

@vstinner
Copy link
Member

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

vstinner commented 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.

@vstinner
Copy link
Member

vstinner commented 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.

@vstinner vstinner closed this as completed Apr 4, 2024
@tacaswell
Copy link
Author

Why are you testing the main branch instead of 3.13 alpha releases?

Because everyone needs a hobby 🤣 https://github.com/tacaswell/build_the_world

I can confirm that this fixes numpy.

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

2 participants