Repository: gwastro/pycbc

Issue:
Can't build PyCBC wheel with numpy 2.0.0rc1
I am unable to build PyCBC in an environment with numpy 2.0.0rc1:

```console
$ pip list installed
Package            Version
------------------ --------
build              1.2.1
colorama           0.4.6
Cython             3.0.10
importlib_metadata 7.1.0
numpy              2.0.0rc1
packaging          24.0
pip                24.0
pyproject_hooks    1.0.0
setuptools         69.5.1
tomli              2.0.1
wheel              0.43.0
zipp               3.17.0
$ python3 -m build . --no-isolation
...
building 'pycbc.waveform.spa_tmplt_cpu' extension
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/pycbc
creating build/temp.linux-x86_64-cpython-311/pycbc/waveform
gcc -pthread -B /home/duncan/opt/mambaforge/envs/test/compiler_compat -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/duncan/opt/mambaforge/envs/test/include -fPIC -O2 -isystem /home/duncan/opt/mambaforge/envs/test/include -fPIC -I/home/duncan/opt/mambaforge/envs/test/lib/python3.11/site-packages/numpy/core/include -I/home/duncan/opt/mambaforge/envs/test/include/python3.11 -c pycbc/waveform/spa_tmplt_cpu.c -o build/temp.linux-x86_64-cpython-311/pycbc/waveform/spa_tmplt_cpu.o -O3 -w -ffast-math -ffinite-math-only -msse4.2 -fopenmp
pycbc/waveform/spa_tmplt_cpu.c:1254:10: fatal error: numpy/arrayobject.h: No such file or directory
 1254 | #include "numpy/arrayobject.h"
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1

ERROR Backend subprocess exited when trying to invoke build_wheel
```

This is because the numpy include path changed with numpy 2.0.0 and PyCBC is hardcoding the path, rather than discovering it dynamically.
```
Can't build PyCBC wheel with numpy 2.0.0rc1
I am unable to build PyCBC in an environment with numpy 2.0.0rc1:

```console
$ pip list installed
Package            Version
------------------ --------
build              1.2.1
colorama           0.4.6
Cython             3.0.10
importlib_metadata 7.1.0
numpy              2.0.0rc1
packaging          24.0
pip                24.0
pyproject_hooks    1.0.0
setuptools         69.5.1
tomli              2.0.1
wheel              0.43.0
zipp               3.17.0
$ python3 -m build . --no-isolation
...
building 'pycbc.waveform.spa_tmplt_cpu' extension
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/pycbc
creating build/temp.linux-x86_64-cpython-311/pycbc/waveform
gcc -pthread -B /home/duncan/opt/mambaforge/envs/test/compiler_compat -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/duncan/opt/mambaforge/envs/test/include -fPIC -O2 -isystem /home/duncan/opt/mambaforge/envs/test/include -fPIC -I/home/duncan/opt/mambaforge/envs/test/lib/python3.11/site-packages/numpy/core/include -I/home/duncan/opt/mambaforge/envs/test/include/python3.11 -c pycbc/waveform/spa_tmplt_cpu.c -o build/temp.linux-x86_64-cpython-311/pycbc/waveform/spa_tmplt_cpu.o -O3 -w -ffast-math -ffinite-math-only -msse4.2 -fopenmp
pycbc/waveform/spa_tmplt_cpu.c:1254:10: fatal error: numpy/arrayobject.h: No such file or directory
 1254 | #include "numpy/arrayobject.h"
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1

ERROR Backend subprocess exited when trying to invoke build_wheel
```

This is because the numpy include path changed with numpy 2.0.0 and PyCBC is hardcoding the path, rather than discovering it dynamically.
```


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -72,10 +72,9 @@ def find_paths(dirname):
 
 class cbuild_ext(_build_ext):
     def run(self):
-        import pkg_resources
-
         # At this point we can be sure pip has already installed numpy
-        numpy_incl = pkg_resources.resource_filename('numpy', 'core/include')
+        import numpy
+        numpy_incl = numpy.get_include()
 
         for ext in self.extensions:
             if (hasattr(ext, 'include_dirs') and


Test patch: