From 80ed1dfa7ff6175b89038f98d935f803509cf86b Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Tue, 30 Jan 2024 22:01:46 +0100 Subject: Add a numpy dependency with pkg-config and configtool methods These are being added for NumPy 2.0 The implementation closely follows the one for the pybind11 dependency. --- mesonbuild/dependencies/python.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'mesonbuild/dependencies/python.py') diff --git a/mesonbuild/dependencies/python.py b/mesonbuild/dependencies/python.py index 342d94e72..6620eff20 100644 --- a/mesonbuild/dependencies/python.py +++ b/mesonbuild/dependencies/python.py @@ -61,6 +61,17 @@ class Pybind11ConfigToolDependency(ConfigToolDependency): self.compile_args = self.get_config_value(['--includes'], 'compile_args') +class NumPyConfigToolDependency(ConfigToolDependency): + + tools = ['numpy-config'] + + def __init__(self, name: str, environment: Environment, kwargs: T.Dict[str, T.Any]): + super().__init__(name, environment, kwargs) + if not self.is_found: + return + self.compile_args = self.get_config_value(['--cflags'], 'compile_args') + + class BasicPythonExternalProgram(ExternalProgram): def __init__(self, name: str, command: T.Optional[T.List[str]] = None, ext_prog: T.Optional[ExternalProgram] = None): @@ -412,3 +423,9 @@ packages['pybind11'] = pybind11_factory = DependencyFactory( [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.CMAKE], configtool_class=Pybind11ConfigToolDependency, ) + +packages['numpy'] = numpy_factory = DependencyFactory( + 'numpy', + [DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL], + configtool_class=NumPyConfigToolDependency, +) -- cgit v1.2.3