From 4002a7d421ff10780c28a3643683af7a9754f87f Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Wed, 23 Nov 2022 23:40:23 +0100 Subject: BLD: enable building NumPy with Meson This enables building with NumPy on Linux and macOS. Windows support should be complete to, but is untested as of now and may need a few tweaks. This contains: - A set of `meson.build` files and related code generation script tweaks, header templates, etc. - One CI job on Linux - Basic docs on using Meson to build NumPy (not yet integrated in the html docs, it's too early for that - this is for early adopters right now). The build should be complete, with the major exception of SIMD support. The full test suite passes. See gh-22546 for the tracking issue with detailed notes on the plan for switching NumPy to Meson as its build system. Co-authored-by: Stefan van der Walt --- doc/source/f2py/code/meson.build | 32 +++++++++++++++++-------------- doc/source/f2py/code/meson_upd.build | 37 ++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 32 deletions(-) (limited to 'doc/source/f2py/code') diff --git a/doc/source/f2py/code/meson.build b/doc/source/f2py/code/meson.build index 04276a176..1d409f2fb 100644 --- a/doc/source/f2py/code/meson.build +++ b/doc/source/f2py/code/meson.build @@ -1,31 +1,35 @@ project('f2py_examples', 'c', version : '0.1', - default_options : ['warning_level=2']) + license: 'BSD-3', + meson_version: '>=0.64.0', + default_options : ['warning_level=2'], +) add_languages('fortran') py_mod = import('python') -py3 = py_mod.find_installation('python3') -py3_dep = py3.dependency() -message(py3.path()) -message(py3.get_install_dir()) +py = py_mod.find_installation(pure: false) +py_dep = py.dependency() -incdir_numpy = run_command(py3, +incdir_numpy = run_command(py, ['-c', 'import os; os.chdir(".."); import numpy; print(numpy.get_include())'], check : true ).stdout().strip() -incdir_f2py = run_command(py3, +incdir_f2py = run_command(py, ['-c', 'import os; os.chdir(".."); import numpy.f2py; print(numpy.f2py.get_include())'], check : true ).stdout().strip() inc_np = include_directories(incdir_numpy, incdir_f2py) -py3.extension_module('fib2', - 'fib1.f', - 'fib2module.c', - incdir_f2py+'/fortranobject.c', - include_directories: inc_np, - dependencies : py3_dep, - install : true) \ No newline at end of file +py.extension_module('fib2', + [ + 'fib1.f', + 'fib2module.c', # note: this assumes f2py was manually run before! + ], + incdir_f2py / 'fortranobject.c', + include_directories: inc_np, + dependencies : py_dep, + install : true +) diff --git a/doc/source/f2py/code/meson_upd.build b/doc/source/f2py/code/meson_upd.build index 44d69d182..5e4b13bae 100644 --- a/doc/source/f2py/code/meson_upd.build +++ b/doc/source/f2py/code/meson_upd.build @@ -1,37 +1,38 @@ project('f2py_examples', 'c', version : '0.1', - default_options : ['warning_level=2']) + license: 'BSD-3', + meson_version: '>=0.64.0', + default_options : ['warning_level=2'], +) add_languages('fortran') py_mod = import('python') -py3 = py_mod.find_installation('python3') -py3_dep = py3.dependency() -message(py3.path()) -message(py3.get_install_dir()) +py = py_mod.find_installation(pure: false) +py_dep = py.dependency() -incdir_numpy = run_command(py3, +incdir_numpy = run_command(py, ['-c', 'import os; os.chdir(".."); import numpy; print(numpy.get_include())'], check : true ).stdout().strip() -incdir_f2py = run_command(py3, +incdir_f2py = run_command(py, ['-c', 'import os; os.chdir(".."); import numpy.f2py; print(numpy.f2py.get_include())'], check : true ).stdout().strip() fibby_source = custom_target('fibbymodule.c', - input : ['fib1.f'], # .f so no F90 wrappers - output : ['fibbymodule.c', 'fibby-f2pywrappers.f'], - command : [ py3, '-m', 'numpy.f2py', '@INPUT@', - '-m', 'fibby', '--lower']) + input : ['fib1.f'], # .f so no F90 wrappers + output : ['fibbymodule.c', 'fibby-f2pywrappers.f'], + command : [py, '-m', 'numpy.f2py', '@INPUT@', '-m', 'fibby', '--lower'] +) inc_np = include_directories(incdir_numpy, incdir_f2py) -py3.extension_module('fibby', - 'fib1.f', - fibby_source, - incdir_f2py+'/fortranobject.c', - include_directories: inc_np, - dependencies : py3_dep, - install : true) +py.extension_module('fibby', + ['fib1.f', fibby_source], + incdir_f2py / 'fortranobject.c', + include_directories: inc_np, + dependencies : py_dep, + install : true +) -- cgit v1.2.1