From e2ab4c4cf0e59a081bb845e459a40695d3331f52 Mon Sep 17 00:00:00 2001 From: ogiorgis Date: Wed, 20 Dec 2023 16:47:29 +0100 Subject: [PATCH] [msonpy] handle transonic --- fluidsim/base/output/meson.build | 10 ++++++ fluidsim/base/time_stepping/meson.build | 3 ++ fluidsim/operators/meson.build | 3 ++ fluidsim/solvers/ns2d/meson.build | 3 ++ fluidsim/solvers/ns2d/output/meson.build | 3 ++ fluidsim/solvers/ns3d/forcing/meson.build | 3 ++ fluidsim/solvers/ns3d/output/meson.build | 3 ++ fluidsim/solvers/ns3d/strat/meson.build | 3 ++ fluidsim/util/meson.build | 3 ++ meson.build | 40 ++++++++++++++++++++++- meson.options | 1 + pyproject.toml | 7 +++- 12 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 meson.options diff --git a/fluidsim/base/output/meson.build b/fluidsim/base/output/meson.build index 5b7f86b2..9c122f9c 100644 --- a/fluidsim/base/output/meson.build +++ b/fluidsim/base/output/meson.build @@ -20,3 +20,13 @@ python_sources = [ 'time_signals_fft.py', ] +py.install_sources( + python_sources, + subdir: 'fluidsim/base/output' +) + +run_command( + ['transonic', '--meson', '--backend', backend, 'increments.py', 'spatiotemporal_spectra.py'], + check: true +) +subdir('__pythran__') diff --git a/fluidsim/base/time_stepping/meson.build b/fluidsim/base/time_stepping/meson.build index 0bce53fc..c5e423eb 100644 --- a/fluidsim/base/time_stepping/meson.build +++ b/fluidsim/base/time_stepping/meson.build @@ -10,3 +10,6 @@ py.install_sources( python_sources, subdir: 'fluidsim/base/time_stepping' ) + +run_command(['transonic', '--meson', '--backend', backend, 'pseudo_spect.py'], check: true) +subdir('__pythran__') diff --git a/fluidsim/operators/meson.build b/fluidsim/operators/meson.build index 832ee060..a6f839c3 100644 --- a/fluidsim/operators/meson.build +++ b/fluidsim/operators/meson.build @@ -16,3 +16,6 @@ py.install_sources( ) subdir('test') + +run_command(['transonic', '--meson', '--backend', backend, 'operators2d.py', 'operators3d.py'], check: true) +subdir('__pythran__') diff --git a/fluidsim/solvers/ns2d/meson.build b/fluidsim/solvers/ns2d/meson.build index 7811344f..2fd843ed 100644 --- a/fluidsim/solvers/ns2d/meson.build +++ b/fluidsim/solvers/ns2d/meson.build @@ -17,3 +17,6 @@ py.install_sources( subdir('bouss') subdir('output') subdir('strat') + +run_command(['transonic', '--meson', '--backend', backend, 'solver.py'], check: true) +subdir('__pythran__') diff --git a/fluidsim/solvers/ns2d/output/meson.build b/fluidsim/solvers/ns2d/output/meson.build index 8b1ea7ba..7a18173f 100644 --- a/fluidsim/solvers/ns2d/output/meson.build +++ b/fluidsim/solvers/ns2d/output/meson.build @@ -12,3 +12,6 @@ py.install_sources( python_sources, subdir: 'fluidsim/solvers/ns2d/output', ) + +run_command(['transonic', '--meson', '--backend', backend, 'spatiotemporal_spectra.py'], check: true) +subdir('__pythran__') diff --git a/fluidsim/solvers/ns3d/forcing/meson.build b/fluidsim/solvers/ns3d/forcing/meson.build index fe76c3ca..5c7e2943 100644 --- a/fluidsim/solvers/ns3d/forcing/meson.build +++ b/fluidsim/solvers/ns3d/forcing/meson.build @@ -8,3 +8,6 @@ py.install_sources( python_sources, subdir: 'fluidsim/solvers/ns3d/forcing', ) + +run_command(['transonic', '--meson', '--backend', backend, 'watu.py'], check: true) +subdir('__pythran__') diff --git a/fluidsim/solvers/ns3d/output/meson.build b/fluidsim/solvers/ns3d/output/meson.build index 97a17e97..2972bf2d 100644 --- a/fluidsim/solvers/ns3d/output/meson.build +++ b/fluidsim/solvers/ns3d/output/meson.build @@ -11,3 +11,6 @@ py.install_sources( python_sources, subdir: 'fluidsim/solvers/ns3d/output', ) + +run_command(['transonic', '--meson', '--backend', backend, 'spatiotemporal_spectra.py'], check: true) +subdir('__pythran__') diff --git a/fluidsim/solvers/ns3d/strat/meson.build b/fluidsim/solvers/ns3d/strat/meson.build index 494e0263..f86d71e5 100644 --- a/fluidsim/solvers/ns3d/strat/meson.build +++ b/fluidsim/solvers/ns3d/strat/meson.build @@ -11,3 +11,6 @@ py.install_sources( ) subdir('output') + +run_command(['transonic', '--meson', '--backend', backend, 'solver.py'], check: true) +subdir('__pythran__') diff --git a/fluidsim/util/meson.build b/fluidsim/util/meson.build index 9795c7eb..5c4a6372 100644 --- a/fluidsim/util/meson.build +++ b/fluidsim/util/meson.build @@ -15,3 +15,6 @@ py.install_sources( subdir('console') subdir('scripts') + +run_command(['transonic', '--meson', '--backend', backend, 'mini_oper_modif_resol.py'], check: true) +subdir('__pythran__') diff --git a/meson.build b/meson.build index 1bef26be..1196757c 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,6 @@ project( 'fluidsim', + 'cpp', version: '0.7.4', license: 'CeCILL', meson_version: '>= 1.1.0', @@ -10,9 +11,46 @@ project( ], ) +backend = get_option('deps_backend') + # https://mesonbuild.com/Python-module.html py_mod = import('python') -py3 = py_mod.find_installation(pure: false) +py = py_mod.find_installation('python3', pure: false) +py_dep = py.dependency() + +incdir_numpy = run_command( + py, + [ + '-c', + '''import os +import numpy as np +try: + incdir = os.path.relpath(np.get_include()) +except Exception: + incdir = np.get_include() +print(incdir)''' + ], + check: true +).stdout().strip() + +inc_np = include_directories(incdir_numpy) +np_dep = declare_dependency(include_directories: inc_np) + +incdir_pythran = run_command( + py, + [ + '-c', + '''import os +import pythran; +incdir = os.path.dirname(pythran.__file__) +try: + incdir = os.path.relpath(incdir) +except Exception: + pass +print(incdir)''' + ], + check: true + ).stdout().strip() pythran = find_program('pythran', native: true) pythran_dep = declare_dependency( diff --git a/meson.options b/meson.options new file mode 100644 index 00000000..91ea2168 --- /dev/null +++ b/meson.options @@ -0,0 +1 @@ +option('deps_backend', type: 'string', value: 'pythran', description: 'pythran(default), cython, numpy, numba') diff --git a/pyproject.toml b/pyproject.toml index 10284182..6c36a909 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,12 @@ [build-system] # Further build requirements - like pythran and mpi4py - come from setup.py via # the PEP 517 interface. -requires = [ "meson-python>=0.15.0", "numpy", "transonic", "pythran>=0.9.7", "setuptools"] +requires = [ + "meson-python", + "numpy", + "transonic@hg+https://foss.heptapod.net/fluiddyn/transonic", + "pythran>=0.9.7", + ] build-backend = 'mesonpy' [project]