From abf1b425ee474765caa6d730852e64f0253aea73 Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 20 Nov 2026 15:06:44 -0500 Subject: [PATCH 1/5] Add tests --- .../py/orbit/core/test_bunch_add_particles.py | 84 +++++++++++++++++++ tests/py/orbit/core/test_bunch_coordinates.py | 39 +++++++++ 2 files changed, 123 insertions(+) create mode 100644 tests/py/orbit/core/test_bunch_add_particles.py create mode 100644 tests/py/orbit/core/test_bunch_coordinates.py diff --git a/tests/py/orbit/core/test_bunch_add_particles.py b/tests/py/orbit/core/test_bunch_add_particles.py new file mode 100644 index 00000000..fa2f997c --- /dev/null +++ b/tests/py/orbit/core/test_bunch_add_particles.py @@ -0,0 +1,84 @@ +import pytest + +from orbit.core.bunch import Bunch + +np = pytest.importorskip("numpy") +pytestmark = pytest.mark.skipif( + not hasattr(Bunch, "addParticles"), reason="requires USE_NUMPY=true" +) + + +def coordinates(bunch): + getters = (bunch.x, bunch.px, bunch.y, bunch.py, bunch.z, bunch.dE) + return np.array([[get(i) for get in getters] for i in range(bunch.getSize())]) + + +@pytest.mark.parametrize("data", [ + np.arange(18).reshape(3, 6).tolist(), + tuple(tuple(range(i, i + 6)) for i in range(3)), + np.arange(18, dtype=np.float64).reshape(3, 6), + np.arange(18, dtype=np.float32).reshape(3, 6), + np.arange(18, dtype=np.int64).reshape(3, 6), + np.arange(36, dtype=float).reshape(3, 12)[:, ::2], + np.asfortranarray(np.arange(18.).reshape(3, 6)), + np.arange(18.).reshape(3, 6)[::-1], + np.arange(18.).reshape(3, 6).astype('>f8'), +]) +def test_add_particles_matches_scalar_append(data): + actual, expected = Bunch(), Bunch() + for bunch in (actual, expected): + bunch.addParticle(*range(6)) + assert actual.addParticles(data) is None + for row in data: + expected.addParticle(*row) + np.testing.assert_array_equal(coordinates(actual), coordinates(expected)) + + +def test_empty_array_is_noop(): + bunch = Bunch() + bunch.addParticle(*range(6)) + assert bunch.addParticles(np.empty((0, 6))) is None + np.testing.assert_array_equal(coordinates(bunch), [range(6)]) + + +@pytest.mark.parametrize("data", [ + [], list(range(6)), np.zeros((6, 2)), np.zeros((2, 6, 1)), 1, + [[0] * 6, [0] * 5], [[0] * 6, ["bad"] * 6], +]) +def test_invalid_input_does_not_modify_bunch(data): + bunch = Bunch() + bunch.addParticle(*range(6)) + with pytest.raises((TypeError, ValueError)): + bunch.addParticles(data) + np.testing.assert_array_equal(coordinates(bunch), [range(6)]) + + +def test_wrong_argument_count(): + bunch = Bunch() + with pytest.raises(TypeError): + bunch.addParticles() + with pytest.raises(TypeError): + bunch.addParticles([], []) + + +def test_particle_attributes_and_compression_match_scalar_append(): + actual, expected = Bunch(), Bunch() + for bunch in (actual, expected): + bunch.addPartAttr("ParticleIdNumber") + bunch.addParticle(*range(6)) + bunch.partAttrValue("ParticleIdNumber", 0, 0, 42) + bunch.addParticle(*range(6)) + bunch.deleteParticleFast(1) + data = np.arange(12.).reshape(2, 6) + actual.addParticles(data) + for row in data: + expected.addParticle(*row) + assert actual.getSize() == expected.getSize() + for bunch in (actual, expected): + bunch.compress() + np.testing.assert_array_equal(coordinates(actual), coordinates(expected)) + for i in range(expected.getSize()): + assert actual.partAttrValue("ParticleIdNumber", i, 0) == expected.partAttrValue( + "ParticleIdNumber", i, 0 + ) + assert actual.partAttrValue("ParticleIdNumber", 0, 0) == 42 diff --git a/tests/py/orbit/core/test_bunch_coordinates.py b/tests/py/orbit/core/test_bunch_coordinates.py new file mode 100644 index 00000000..27962595 --- /dev/null +++ b/tests/py/orbit/core/test_bunch_coordinates.py @@ -0,0 +1,39 @@ +import pytest + +from orbit.core.bunch import Bunch + +np = pytest.importorskip("numpy") +pytestmark = pytest.mark.skipif( + not hasattr(Bunch, "coordinates"), reason="requires USE_NUMPY=true" +) + + +@pytest.mark.parametrize("count", [0, 1, 1000]) +def test_coordinates_shape_values_and_round_trip(count): + expected = np.arange(count * 6, dtype=np.float64).reshape(count, 6) + bunch = Bunch() + for row in expected: + bunch.addParticle(*row) + + actual = bunch.coordinates() + assert actual.shape == (count, 6) + assert actual.dtype == np.float64 + assert actual.flags.c_contiguous + assert actual.flags.owndata + np.testing.assert_array_equal(actual, expected) + + other = Bunch() + other.addParticles(actual) + np.testing.assert_array_equal(other.coordinates(), expected) + + +def test_coordinates_is_independent_snapshot(): + bunch = Bunch() + bunch.addParticle(*range(6)) + snapshot = bunch.coordinates() + snapshot[0, 0] = -100 + assert bunch.x(0) == 0 + bunch.x(0, 42) + assert snapshot[0, 0] == -100 + bunch.deleteAllParticles() + np.testing.assert_array_equal(snapshot, [[-100, 1, 2, 3, 4, 5]]) From 7a7e005745aec76115aeb9b625b8b28403013ddd Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 20 Nov 2026 15:09:01 -0500 Subject: [PATCH 2/5] Implement Bunch.addParticles(ArrayLike) and Bunch.coordinates() --- meson_options.txt | 1 + src/meson.build | 8 ++++ src/orbit/wrap_bunch.cc | 81 +++++++++++++++++++++++++++++++++++++++++ src/orbit/wrap_bunch.hh | 2 +- 4 files changed, 91 insertions(+), 1 deletion(-) diff --git a/meson_options.txt b/meson_options.txt index 0a1c8713..fae32dab 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,4 +1,5 @@ option('USE_MPI', type: 'string', value: 'auto', description: 'Choose MPI implementation (mpich, openmpi, none, auto)') option('USE_FFTW_THREADS', type: 'boolean', value: false, description: 'Build with threaded version of FFTW') option('USE_OPENMP', type: 'boolean', value: false, description: 'Build with OpenMP (multi-threading) support') +option('USE_NUMPY', type: 'boolean', value: false, description: 'Build Bunch.addParticles and Bunch.coordinates with the NumPy C API') diff --git a/src/meson.build b/src/meson.build index 45432036..1e8a6796 100644 --- a/src/meson.build +++ b/src/meson.build @@ -12,6 +12,14 @@ endif dependencies = [] dependencies += python.dependency() +if get_option('USE_NUMPY') + numpy_include = run_command( + python, ['-c', 'import numpy; print(numpy.get_include())'], + check: true, + ).stdout().strip() + dependencies += declare_dependency(include_directories: include_directories(numpy_include)) + add_project_arguments('-DWITH_NUMPY', language: 'cpp') +endif dep_fftw = dependency('fftw3', version: '>= 3.0.0', required: true) dependencies += dep_fftw diff --git a/src/orbit/wrap_bunch.cc b/src/orbit/wrap_bunch.cc index 8bda038d..54d5a170 100644 --- a/src/orbit/wrap_bunch.cc +++ b/src/orbit/wrap_bunch.cc @@ -9,6 +9,10 @@ // /////////////////////////////////////////////////////////////////////////// #include "wrap_bunch.hh" +#ifdef WITH_NUMPY +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION +#include +#endif #include "wrap_syncpart.hh" #include "wrap_bunch_twiss_analysis.hh" #include "wrap_bunch_tune_analysis.hh" @@ -124,6 +128,70 @@ namespace wrap_orbit_bunch{ } +#ifdef WITH_NUMPY + //Returns an owned snapshot without compressing or filtering deleted particles. + static PyObject* Bunch_coordinates(PyObject *self, PyObject*) + { + Bunch* cpp_bunch = static_cast( + reinterpret_cast(self)->cpp_obj); + + const int count = cpp_bunch->getSize(); + npy_intp shape[2] = {static_cast(count), 6}; + + PyObject* result = PyArray_SimpleNew(2, shape, NPY_DOUBLE); + + if(result == NULL) return NULL; + + double* data = static_cast( + PyArray_DATA(reinterpret_cast(result))); + + double** coordinates = cpp_bunch->coordArr(); + + #pragma omp parallel for schedule(static) + for(int i = 0; i < count; ++i) { + for(int j = 0; j < 6; ++j) { + data[static_cast(i)*6 + j] = coordinates[i][j]; + } + } + + return result; + } + + //Appends local particle coordinates from an array-like object of shape (N, 6). + static PyObject* Bunch_addParticles(PyObject *self, PyObject *coordinates) + { + PyArrayObject* array = reinterpret_cast(PyArray_FROM_OTF( + coordinates, NPY_DOUBLE, NPY_ARRAY_IN_ARRAY)); + + if(array == NULL) return NULL; + + if(PyArray_NDIM(array) != 2 || PyArray_DIM(array,1) != 6){ + Py_DECREF(array); + PyErr_SetString(PyExc_ValueError, + "addParticles expects coordinates with shape (N, 6)"); + return NULL; + } + + Bunch* cpp_bunch = static_cast( + reinterpret_cast(self)->cpp_obj); + + const double* data = static_cast(PyArray_DATA(array)); + const npy_intp count = PyArray_DIM(array,0); + + // TODO: Due to Bunch's lack of a bulk-append method, it's not currently + // thread-safe to parallelize this loop, but doing it serially is already pretty fast. + // Investigate the potential for parallelization later. + for(npy_intp i = 0; i < count; ++i) { + const double* row = data + 6*i; + cpp_bunch->addParticle(row[0],row[1],row[2],row[3],row[4],row[5]); + } + + Py_DECREF(array); + Py_RETURN_NONE; + } + +#endif + //removes a particle to the Bunch object //returns the number of particles in the bunch //this is implementation of the deleteParticle(int index) method @@ -1192,6 +1260,16 @@ namespace wrap_orbit_bunch{ { "setMPIComm", Bunch_setMPIComm ,METH_VARARGS,"Sets a new MPI Comm for this bunch"}, { "getSyncParticle", Bunch_getSyncParticle ,METH_VARARGS,"Returns syncParticle class instance"}, { "addParticle", Bunch_addParticle ,METH_VARARGS,"Adds a macro-particle to the bunch"}, +#ifdef WITH_NUMPY + { "addParticles", Bunch_addParticles ,METH_O, + "Append local coordinates of shape (N, 6), ordered (x, xp, y, yp, z, dE). Returns None."}, + { "coordinates", Bunch_coordinates ,METH_NOARGS, + "Return an independent C-contiguous float64 array of local coordinates.\n" + "Shape (getSize(), 6); columns (x, xp, y, yp, z, dE), in existing units.\n" + "No MPI communication, particle attributes, or metadata are included.\n" + "Does not compress or filter deleted particles. Call compress() first if\n" + "particles have been deleted; otherwise addParticles() can revive dead slots."}, +#endif { "deleteParticle", Bunch_deleteParticle ,METH_VARARGS,"Removes macro-particle from the bunch and call compress inside"}, { "deleteParticleFast", Bunch_deleteParticleFast ,METH_VARARGS,"Removes macro-particle from the bunch very fast"}, { "recoverParticle", Bunch_recoverParticle ,METH_VARARGS,"Recovers a particle marked for removal"}, @@ -1315,6 +1393,9 @@ extern "C" { /* The name of the function was changed to avoid collision with PyImport magic naming */ PyMODINIT_FUNC initbunch(void) { +#ifdef WITH_NUMPY + import_array(); +#endif //check that the Bunch wrapper is ready if(PyType_Ready(&pyORBIT_Bunch_Type) < 0) return NULL; Py_INCREF(&pyORBIT_Bunch_Type); diff --git a/src/orbit/wrap_bunch.hh b/src/orbit/wrap_bunch.hh index f096625c..1c2a2530 100644 --- a/src/orbit/wrap_bunch.hh +++ b/src/orbit/wrap_bunch.hh @@ -16,7 +16,7 @@ // INCLUDE FILES // /////////////////////////////////////////////////////////////////////////// -#include "Python.h" +#include #ifdef __cplusplus extern "C" { From a7e8fdc395a5795a3a1a84c04ddac52deea11d6c Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 20 Nov 2026 15:16:43 -0500 Subject: [PATCH 3/5] Update CI. --- .github/workflows/compilation.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index 5776d887..4c6323d0 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -116,7 +116,9 @@ jobs: pip install -U pip pip install -r requirements.txt pip install -U setuptools + pip install numpy pip install --no-build-isolation --editable ".[numpy]" \ + --config-settings=setup-args="-DUSE_NUMPY=true" \ --config-settings=setup-args="-DUSE_FFTW_THREADS=true" \ --config-settings=setup-args="-DUSE_OPENMP=true" From fb912c0ca2034ba2a4d4e505e426312737da932b Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 20 Nov 2026 15:27:09 -0500 Subject: [PATCH 4/5] Ship stub file with compiled extensions --- py/orbit/core/bunch.pyi | 239 ++++++++++++++++++++++++++++++++++++++ py/orbit/core/meson.build | 2 + py/orbit/core/py.typed | 0 3 files changed, 241 insertions(+) create mode 100644 py/orbit/core/bunch.pyi create mode 100644 py/orbit/core/py.typed diff --git a/py/orbit/core/bunch.pyi b/py/orbit/core/bunch.pyi new file mode 100644 index 00000000..22e9a8b9 --- /dev/null +++ b/py/orbit/core/bunch.pyi @@ -0,0 +1,239 @@ +"""Types for orbit.core.bunch, including optional USE_NUMPY methods.""" + +from typing import Any, overload + +import numpy as np +from numpy.typing import ArrayLike, NDArray + +class Bunch: + def __init__(self) -> None: ... + # Communicators are extension objects from the currently untyped orbit_mpi module. + def getMPIComm(self) -> Any: ... + def setMPIComm(self, mpi_comm: Any, /) -> None: ... + def getSyncParticle(self) -> SyncParticle: ... + def addParticle( + self, x: float, xp: float, y: float, yp: float, z: float, dE: float, / + ) -> int: ... + def addParticles(self, coordinates: ArrayLike, /) -> None: + """Append local (N, 6) coordinates in (x, xp, y, yp, z, dE) order. + + Requires a USE_NUMPY build. Uses existing units; accepts nested sequences + and compatible NumPy arrays. Does not compress or distribute particles. + """ + def coordinates(self) -> NDArray[np.float64]: + """Return an owned, C-contiguous (getSize(), 6) local-coordinate snapshot. + + Requires a USE_NUMPY build. Columns are (x, xp, y, yp, z, dE) in existing + units. No MPI communication, attributes, or reference-particle metadata. + Does not compress or filter dead slots: call compress() after deletions + before exporting to avoid reviving deleted particles via addParticles(). + """ + def deleteParticle(self, index: int, /) -> int: ... + def deleteParticleFast(self, index: int, /) -> int: ... + def recoverParticle(self, index: int, /) -> None: ... + def deleteAllParticles(self) -> None: ... + def compress(self) -> None: ... + @overload + def x(self, index: int, /) -> float: ... + @overload + def x(self, index: int, value: float, /) -> float: ... + @overload + def y(self, index: int, /) -> float: ... + @overload + def y(self, index: int, value: float, /) -> float: ... + @overload + def z(self, index: int, /) -> float: ... + @overload + def z(self, index: int, value: float, /) -> float: ... + @overload + def px(self, index: int, /) -> float: ... + @overload + def px(self, index: int, value: float, /) -> float: ... + @overload + def py(self, index: int, /) -> float: ... + @overload + def py(self, index: int, value: float, /) -> float: ... + @overload + def pz(self, index: int, /) -> float: ... + @overload + def pz(self, index: int, value: float, /) -> float: ... + @overload + def xp(self, index: int, /) -> float: ... + @overload + def xp(self, index: int, value: float, /) -> float: ... + @overload + def yp(self, index: int, /) -> float: ... + @overload + def yp(self, index: int, value: float, /) -> float: ... + @overload + def dE(self, index: int, /) -> float: ... + @overload + def dE(self, index: int, value: float, /) -> float: ... + def flag(self, index: int, /) -> int: ... + def ringwrap(self, ring_length: float, /) -> None: ... + @overload + def mass(self) -> float: ... + @overload + def mass(self, value: float, /) -> float: ... + def classicalRadius(self) -> float: ... + def B_Rho(self) -> float: ... + @overload + def charge(self) -> float: ... + @overload + def charge(self, value: float, /) -> float: ... + @overload + def macroSize(self) -> float: ... + @overload + def macroSize(self, value: float, /) -> float: ... + def initBunchAttr(self, file_name: str, /) -> None: ... + @overload + def bunchAttrDouble(self, name: str, /) -> float: ... + @overload + def bunchAttrDouble(self, name: str, value: float, /) -> float: ... + @overload + def bunchAttrInt(self, name: str, /) -> int: ... + @overload + def bunchAttrInt(self, name: str, value: int, /) -> int: ... + def bunchAttrDoubleNames(self) -> tuple[str, ...]: ... + def bunchAttrIntNames(self) -> tuple[str, ...]: ... + def hasBunchAttrDouble(self, name: str, /) -> int: ... + def hasBunchAttrInt(self, name: str, /) -> int: ... + def addPartAttr(self, name: str, params: dict[str, float] = ..., /) -> None: ... + def removePartAttr(self, name: str, /) -> None: ... + def removeAllPartAttr(self) -> None: ... + def getPartAttrNames(self) -> tuple[str, ...]: ... + def getPartAttrDicts(self) -> dict[str, dict[str, float]]: ... + def getPossiblePartAttrNames(self) -> tuple[str, ...]: ... + def clearAllPartAttrAndMemorize(self) -> None: ... + def restoreAllPartAttrFromMemory(self) -> None: ... + def hasPartAttr(self, name: str, /) -> int: ... + def readPartAttrNames(self, file_name: str, /) -> tuple[str, ...]: ... + def readPartAttrDicts(self, file_name: str, /) -> dict[str, dict[str, float]]: ... + def readPartAttr(self, file_name: str, /) -> None: ... + def getPartAttrSize(self, name: str, /) -> int: ... + @overload + def partAttrValue(self, name: str, part_index: int, attr_index: int, /) -> float: ... + @overload + def partAttrValue( + self, name: str, part_index: int, attr_index: int, value: float, / + ) -> float: ... + def getSize(self) -> int: ... + def getSizeGlobal(self) -> int: ... + def getSizeGlobalFromMemory(self) -> int: ... + def getTotalCount(self) -> int: ... + def getCapacity(self) -> int: ... + def dumpBunch(self, file_name: str = ..., /) -> None: ... + def readBunch(self, file_name: str, nParts: int = ..., /) -> None: ... + def copyEmptyBunchTo(self, target: Bunch, /) -> None: ... + def copyBunchTo(self, target: Bunch, /) -> None: ... + def addParticlesTo(self, target: Bunch, /) -> None: ... + + +class SyncParticle: + """Reference particle owned by a Bunch; obtain via Bunch.getSyncParticle(). + + Direct construction is reserved for the Bunch wrapper's initialization. + """ + + def __init__(self, bunch: Bunch, /) -> None: ... + def mass(self) -> float: ... + @overload + def momentum(self) -> float: ... + @overload + def momentum(self, value: float, /) -> float: ... + def beta(self) -> float: ... + def gamma(self) -> float: ... + @overload + def kinEnergy(self) -> float: ... + @overload + def kinEnergy(self, value: float, /) -> float: ... + @overload + def time(self) -> float: ... + @overload + def time(self, value: float, /) -> None: ... + @overload + def x(self) -> float: ... + @overload + def x(self, value: float, /) -> None: ... + @overload + def y(self) -> float: ... + @overload + def y(self, value: float, /) -> None: ... + @overload + def z(self) -> float: ... + @overload + def z(self, value: float, /) -> None: ... + @overload + def px(self) -> float: ... + @overload + def px(self, value: float, /) -> None: ... + @overload + def py(self) -> float: ... + @overload + def py(self, value: float, /) -> None: ... + @overload + def pz(self) -> float: ... + @overload + def pz(self, value: float, /) -> None: ... + @overload + def pVector(self) -> tuple[float, float, float]: ... + @overload + def pVector(self, value: tuple[float, float, float], /) -> None: ... + @overload + def rVector(self) -> tuple[float, float, float]: ... + @overload + def rVector(self, value: tuple[float, float, float], /) -> None: ... + @overload + def nxVector(self) -> tuple[float, float, float]: ... + @overload + def nxVector(self, value: tuple[float, float, float], /) -> None: ... + def nyVector(self) -> tuple[float, float, float]: ... + def energyToMomentum(self, value: float, /) -> float: ... + def momentumToEnergy(self, value: float, /) -> float: ... + + +class BunchTwissAnalysis: + def __init__(self) -> None: ... + def analyzeBunch(self, bunch: Bunch, /) -> None: ... + def computeBunchMoments( + self, bunch: Bunch, order: int, dispterm: int, emitnormterm: int, / + ) -> None: ... + def getCorrelation(self, ic: int, jc: int, /) -> float: ... + def getBunchMoment(self, i: int, j: int, /) -> float: ... + def getAverage(self, ic: int, /) -> float: ... + def getGlobalCount(self) -> int: ... + def getGlobalMacrosize(self) -> float: ... + def getEmittance(self, ic: int, /) -> float: ... + def getEmittanceNormalized(self, ic: int, /) -> float: ... + def getAlpha(self, ic: int, /) -> float: ... + def getBeta(self, ic: int, /) -> float: ... + def getGamma(self, ic: int, /) -> float: ... + def getTwiss(self, ic: int, /) -> tuple[float, float, float, float]: ... + def getDispersion(self, ic: int, /) -> float: ... + def getDispersionDerivative(self, ic: int, /) -> float: ... + def getEffectiveEmittance(self, ic: int, /) -> float: ... + def getEffectiveAlpha(self, ic: int, /) -> float: ... + def getEffectiveBeta(self, ic: int, /) -> float: ... + def getEffectiveGamma(self, ic: int, /) -> float: ... + + +class BunchTuneAnalysis: + def __init__(self) -> None: ... + def analyzeBunch(self, bunch: Bunch, /) -> None: ... + def setNormMatrixElement(self, i: int, j: int, value: float, /) -> None: ... + def getNormMatrixElement(self, i: int, j: int, /) -> float: ... + def setNormMatrixFromTwiss( + self, betax: float, alphax: float, etax: float, etapx: float, + betay: float, alphay: float, / + ) -> None: ... + + +class SynchPartRedefinitionZdE: + def __init__(self) -> None: ... + def analyzeBunch(self, bunch: Bunch, /) -> None: ... + def center_dE(self, bunch: Bunch, /) -> None: ... + def center_Z(self, bunch: Bunch, /) -> None: ... + def shift_dE(self, bunch: Bunch, delta_E: float, /) -> None: ... + def shift_Z(self, bunch: Bunch, delta_z: float, /) -> None: ... + def getAvg_Z(self) -> float: ... + def getAvg_dE(self) -> float: ... diff --git a/py/orbit/core/meson.build b/py/orbit/core/meson.build index 71c6c920..9a8c4bca 100644 --- a/py/orbit/core/meson.build +++ b/py/orbit/core/meson.build @@ -1,6 +1,8 @@ py_sources = files([ '__init__.py', + 'bunch.pyi', + 'py.typed', ]) python.install_sources( diff --git a/py/orbit/core/py.typed b/py/orbit/core/py.typed new file mode 100644 index 00000000..e69de29b From c4eb1cafa4952bb683a36dde06ceeb53bc12415a Mon Sep 17 00:00:00 2001 From: "Wood, Tony" Date: Fri, 20 Nov 2026 15:36:10 -0500 Subject: [PATCH 5/5] Let's try this instead --- src/meson.build | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/meson.build b/src/meson.build index 1e8a6796..75be7f70 100644 --- a/src/meson.build +++ b/src/meson.build @@ -13,11 +13,7 @@ dependencies = [] dependencies += python.dependency() if get_option('USE_NUMPY') - numpy_include = run_command( - python, ['-c', 'import numpy; print(numpy.get_include())'], - check: true, - ).stdout().strip() - dependencies += declare_dependency(include_directories: include_directories(numpy_include)) + dependencies += dependency('numpy') add_project_arguments('-DWITH_NUMPY', language: 'cpp') endif dep_fftw = dependency('fftw3', version: '>= 3.0.0', required: true)