From c562b9efff1547602fd1742cf6de8f3047b25772 Mon Sep 17 00:00:00 2001 From: Lehman Garrison Date: Fri, 26 Jul 2024 14:09:16 -0400 Subject: [PATCH 1/2] Fix headers and include paths for NumPy 2 (currently breaks NumPy 1 build support) --- common.mk | 4 ++-- mocks/python_bindings/_countpairs_mocks.c | 2 +- theory/python_bindings/_countpairs.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common.mk b/common.mk index d390366d..1ea47d34 100644 --- a/common.mk +++ b/common.mk @@ -506,14 +506,14 @@ ifeq ($(DO_CHECKS), 1) # NUMPY is available -> next step should not fail # That's why we are not checking if the NUMPY_INCL_FLAG is defined. ifeq ($(NUMPY_CHECKED), 0) - export NUMPY_INCL_FLAG := $(shell $(PYTHON) -c "from __future__ import print_function; import numpy; print('-isystem ' + numpy.__path__[0] + '/core/include/numpy/')") + export NUMPY_INCL_FLAG := $(shell $(PYTHON) -c "from __future__ import print_function; import numpy; print('-isystem ' + numpy.__path__[0] + '/_core/include/')") # Take the second word -> the path (the first word is "isystem") NUMPY_INCL_PATH := $(word 2, ${NUMPY_INCL_FLAG}) # Now check that the 'arrayobject.h' file is present in the # supposed numpy directory. Otherwise, compilation will fail. # The absence of the file likely indicates a missing numpy-devel # package (see issue #134 on github) - NUMPY_NEEDED_HEADER_FILE := ${NUMPY_INCL_PATH}arrayobject.h + NUMPY_NEEDED_HEADER_FILE := ${NUMPY_INCL_PATH}numpy/arrayobject.h ifeq (,$(wildcard ${NUMPY_NEEDED_HEADER_FILE})) $(error Required $(ccred)numpy headers$(ccreset) are missing...stopping the compilation. You might be able to fix this by installing $(ccblue)numpy-devel$(ccreset)) endif diff --git a/mocks/python_bindings/_countpairs_mocks.c b/mocks/python_bindings/_countpairs_mocks.c index cbe41afa..e4f386a9 100644 --- a/mocks/python_bindings/_countpairs_mocks.c +++ b/mocks/python_bindings/_countpairs_mocks.c @@ -10,7 +10,7 @@ #include /* Now, include the numpy header*/ -#include +#include //for correlation functions #include "countpairs_rp_pi_mocks.h" diff --git a/theory/python_bindings/_countpairs.c b/theory/python_bindings/_countpairs.c index 8bc3c93c..9f52ca3e 100644 --- a/theory/python_bindings/_countpairs.c +++ b/theory/python_bindings/_countpairs.c @@ -15,7 +15,7 @@ #include /* Now, include the numpy header*/ -#include +#include //for correlation functions #include "countpairs.h" From 3a782c763ed222898b6aec673c036b3853f45299 Mon Sep 17 00:00:00 2001 From: Lehman Garrison Date: Sat, 27 Jul 2024 10:16:56 -0400 Subject: [PATCH 2/2] Fix NumPy 1 build by using numpy.get_include() --- common.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common.mk b/common.mk index 1ea47d34..147f277d 100644 --- a/common.mk +++ b/common.mk @@ -506,14 +506,14 @@ ifeq ($(DO_CHECKS), 1) # NUMPY is available -> next step should not fail # That's why we are not checking if the NUMPY_INCL_FLAG is defined. ifeq ($(NUMPY_CHECKED), 0) - export NUMPY_INCL_FLAG := $(shell $(PYTHON) -c "from __future__ import print_function; import numpy; print('-isystem ' + numpy.__path__[0] + '/_core/include/')") + export NUMPY_INCL_FLAG := $(shell $(PYTHON) -c "from __future__ import print_function; import numpy; print('-isystem ' + numpy.get_include())") # Take the second word -> the path (the first word is "isystem") NUMPY_INCL_PATH := $(word 2, ${NUMPY_INCL_FLAG}) # Now check that the 'arrayobject.h' file is present in the # supposed numpy directory. Otherwise, compilation will fail. # The absence of the file likely indicates a missing numpy-devel # package (see issue #134 on github) - NUMPY_NEEDED_HEADER_FILE := ${NUMPY_INCL_PATH}numpy/arrayobject.h + NUMPY_NEEDED_HEADER_FILE := ${NUMPY_INCL_PATH}/numpy/arrayobject.h ifeq (,$(wildcard ${NUMPY_NEEDED_HEADER_FILE})) $(error Required $(ccred)numpy headers$(ccreset) are missing...stopping the compilation. You might be able to fix this by installing $(ccblue)numpy-devel$(ccreset)) endif