We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug
When numpy version changes (e.g. 1.26 → 2.1), meson setup --reconfigure need to explicitly be invoked otherwise missing header error messages results.
meson setup --reconfigure
(more generally, how can run_command output be made dependent on something else?)
run_command
To Reproduce
# if there's a previous test environment delete it conda deactivate #conda env remove -n test export PYTHONNOUSERSITE=1 conda create -n test python==3.12 numpy==1.26.4 meson ninja pkg-config conda activate test ## cat > hello_world.c << 'EOF' #define PY_SSIZE_T_CLEAN #include <Python.h> #include <numpy/arrayobject.h> static PyObject* hello_world(PyObject* self, PyObject* args) { npy_intp dims[1] = {5}; PyObject* array = PyArray_SimpleNew(1, dims, NPY_DOUBLE); if (array == NULL) { return NULL; } double* data = (double*) PyArray_DATA((PyArrayObject*) array); for (int i = 0; i < 5; i++) { data[i] = (double)(i + 1); } PyObject* repr = PyObject_Repr(array); const char* str = PyUnicode_AsUTF8(repr); printf("Hello, World! Here is a NumPy array: %s\n", str); Py_XDECREF(repr); Py_DECREF(array); Py_RETURN_NONE; } static PyMethodDef HelloWorldMethods[] = { {"hello", hello_world, METH_VARARGS, "Print 'Hello, World!' and a NumPy array"}, {NULL, NULL, 0, NULL} }; static struct PyModuleDef helloworldmodule = { PyModuleDef_HEAD_INIT, "hello_world", NULL, -1, HelloWorldMethods }; PyMODINIT_FUNC PyInit_hello_world(void) { import_array(); return PyModule_Create(&helloworldmodule); } EOF cat > meson.build << 'EOF' project('hello_world', 'c', version: '0.1.0') py_module = import('python') py = py_module.find_installation(pure: false) inc_numpy = run_command( py, [ '-c', 'import numpy; print(numpy.get_include())' ], check: true, ).stdout().strip() # following instruction in https://numpy.org/doc/stable/f2py/buildtools/meson.html#using-via-meson numpy_dep = declare_dependency(include_directories: inc_numpy) #numpy_dep = dependency('numpy') # doesn't work because numpy-config isn't available before numpy 2.0 hello_world = py.extension_module('hello_world', 'hello_world.c', dependencies: [numpy_dep], install: true, ) EOF meson setup ./build meson compile -C ./build --verbose conda install -y numpy==2.1.0 meson compile -C ./build --verbose
→
INFO: autodetecting backend as ninja INFO: calculating backend command to run: /home/aaa/miniforge3/envs/test/bin/ninja -C /tmp/c/src/build -v ninja: Entering directory `/tmp/c/src/build' [1/2] ccache cc -Ihello_world.cpython-312-x86_64-linux-gnu.so.p -I. -I.. -I/home/aaa/miniforge3/envs/test/lib/python3.12/site-packages/numpy/core/include -I/home/aaa/miniforge3/envs/test/include/python3.12 -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -fPIC -MD -MQ hello_world.cpython-312-x86_64-linux-gnu.so.p/hello_world.c.o -MF hello_world.cpython-312-x86_64-linux-gnu.so.p/hello_world.c.o.d -o hello_world.cpython-312-x86_64-linux-gnu.so.p/hello_world.c.o -c ../hello_world.c FAILED: hello_world.cpython-312-x86_64-linux-gnu.so.p/hello_world.c.o ccache cc -Ihello_world.cpython-312-x86_64-linux-gnu.so.p -I. -I.. -I/home/aaa/miniforge3/envs/test/lib/python3.12/site-packages/numpy/core/include -I/home/aaa/miniforge3/envs/test/include/python3.12 -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -O0 -g -fPIC -MD -MQ hello_world.cpython-312-x86_64-linux-gnu.so.p/hello_world.c.o -MF hello_world.cpython-312-x86_64-linux-gnu.so.p/hello_world.c.o.d -o hello_world.cpython-312-x86_64-linux-gnu.so.p/hello_world.c.o -c ../hello_world.c ../hello_world.c:3:10: fatal error: numpy/arrayobject.h: No such file or directory 3 | #include <numpy/arrayobject.h> | ^~~~~~~~~~~~~~~~~~~~~ compilation terminated. ninja: build stopped: subcommand failed.
Expected behavior
The equivalent of meson setup --reconfigure ./build is automatically executed.
meson setup --reconfigure ./build
system parameters
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
When numpy version changes (e.g. 1.26 → 2.1),
meson setup --reconfigure
need to explicitly be invoked otherwise missing header error messages results.(more generally, how can
run_command
output be made dependent on something else?)To Reproduce
→
Expected behavior
The equivalent of
meson setup --reconfigure ./build
is automatically executed.system parameters
The text was updated successfully, but these errors were encountered: