diff --git a/plugins/fluidfft-build-deps/fluidfft_build_deps/src_cy/make_files_with_mako.py b/plugins/fluidfft-build-deps/fluidfft_build_deps/src_cy/make_files_with_mako.py index 7434711..d7900b5 100644 --- a/plugins/fluidfft-build-deps/fluidfft_build_deps/src_cy/make_files_with_mako.py +++ b/plugins/fluidfft-build-deps/fluidfft_build_deps/src_cy/make_files_with_mako.py @@ -2,12 +2,8 @@ from os.path import join from datetime import datetime -here = os.path.abspath(os.path.dirname(__file__)) - -path_fluidfft = os.path.abspath(os.path.join(here, "..", "src", "fluidfft")) -path2d = os.path.join(path_fluidfft, "fft2d") -path3d = os.path.join(path_fluidfft, "fft3d") - +HERE = os.path.abspath(os.path.dirname(__file__)) +CURRENT_DIR = os.getcwd() def load_template(filename): """Load template file using Mako or Jinja2. @@ -42,12 +38,12 @@ def load_template(filename): "", "%", "##", - loader=FileSystemLoader(here), + loader=FileSystemLoader(HERE), ) print("Falling back to Jinja2 as the template library...") return env.get_template(filename) else: - return Template(filename=join(here, filename)) + return Template(filename=join(HERE, filename)) def modification_date(filename): @@ -56,18 +52,19 @@ def modification_date(filename): def get_path_files(module_name): - if module_name.startswith("fft2d"): - path_package = path2d - elif module_name.startswith("fft3d"): - path_package = path3d - - path_pyx = join(path_package, module_name + ".pyx") - path_pxd = join(path_package, module_name + ".pxd") + path_pyx = join(CURRENT_DIR, module_name + ".pyx") + path_pxd = join(CURRENT_DIR, module_name + ".pxd") return path_pyx, path_pxd -def make_file(module_name, class_name, numpy_api, templates): +def make_file(module_name, class_name, numpy_api): + templates = { + "fft2d_pyx": load_template("template2d_mako.pyx"), + "fft2d_pxd": load_template("template2d_mako.pxd"), + "fft3d_pyx": load_template("template3d_mako.pyx"), + "fft3d_pxd": load_template("template3d_mako.pxd"), + } if module_name.startswith("fft2d"): t_pyx = templates["fft2d_pyx"] t_pxd = templates["fft2d_pxd"] @@ -75,8 +72,6 @@ def make_file(module_name, class_name, numpy_api, templates): t_pyx = templates["fft3d_pyx"] t_pxd = templates["fft3d_pxd"] - path_pyx, path_pxd = get_path_files(module_name) - # Generate pyx and pxd files for path, template in zip(get_path_files(module_name), (t_pyx, t_pxd)): if not os.path.exists(path): @@ -113,16 +108,8 @@ def make_file(module_name, class_name, numpy_api, templates): def make_pyx_files(): - templates = {} - - templates["fft2d_pyx"] = load_template("template2d_mako.pyx") - templates["fft2d_pxd"] = load_template("template2d_mako.pxd") - - templates["fft3d_pyx"] = load_template("template3d_mako.pyx") - templates["fft3d_pxd"] = load_template("template3d_mako.pxd") - for module_name, class_name, numpy_api in variables: - make_file(module_name, class_name, numpy_api, templates) + make_file(module_name, class_name, numpy_api) def _remove(path): diff --git a/plugins/fluidfft-fftw/pyproject.toml b/plugins/fluidfft-fftw/pyproject.toml index 557000d..cfd8f40 100644 --- a/plugins/fluidfft-fftw/pyproject.toml +++ b/plugins/fluidfft-fftw/pyproject.toml @@ -6,6 +6,7 @@ requires = [ "fluidfft_build_deps>=0.0.1", "pythran>=0.9.7", "jinja2", + "mako", "cython", ] build-backend = 'mesonpy' diff --git a/plugins/fluidfft-fftw/src/fluidfft_fftw/fft1d/__init__.py b/plugins/fluidfft-fftw/src/fluidfft_fftw/fft1d/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/fluidfft-fftw/src/fluidfft_fftw/fft1d/meson.build b/plugins/fluidfft-fftw/src/fluidfft_fftw/fft1d/meson.build deleted file mode 100644 index 661195c..0000000 --- a/plugins/fluidfft-fftw/src/fluidfft_fftw/fft1d/meson.build +++ /dev/null @@ -1,8 +0,0 @@ -python_sources = [ - '__init__.py', -] - -py.install_sources( - python_sources, - subdir: 'fluidfft-fftw/ftt1d' -) diff --git a/plugins/fluidfft-fftw/src/fluidfft_fftw/fft2d/meson.build b/plugins/fluidfft-fftw/src/fluidfft_fftw/fft2d/meson.build index 317520b..097ca66 100644 --- a/plugins/fluidfft-fftw/src/fluidfft_fftw/fft2d/meson.build +++ b/plugins/fluidfft-fftw/src/fluidfft_fftw/fft2d/meson.build @@ -7,7 +7,17 @@ py.install_sources( subdir: 'fluidfft-fftw/ftt2d' ) -cpp_path = run_command( +run_command( + py, + [ + '-c', + '''from fluidfft_build_deps.src_cy.make_files_with_mako import make_file +make_file("fft2d_with_fftw1d", "FFT2DWithFFTW1D", "numpy")''' + ], + check: true +) + +src_cpp_path = run_command( py, [ '-c', @@ -17,9 +27,22 @@ print(fluidfft_build_deps.src_cpp.__path__[0])''' check: true ).stdout().strip() +base_sources = ['base_fft.h'] +foreach filename : base_sources + src = join_paths(src_cpp_path, 'base', filename) + dest = join_paths(meson.current_source_dir(), filename) + run_command('cp', src, dest, check : true) +endforeach -run_command(['transonic', '--meson', '--backend', backend, 'operators2d.py', 'operators3d.py'], check: true) - -foreach be : backends - subdir('__' + be + '__') +sources = ['base_fft2d.h', 'fft2d_with_fftw1d.cpp', 'fft2d_with_fftw1d.h'] +foreach filename : sources + src = join_paths(src_cpp_path, '2d', filename) + dest = join_paths(meson.current_source_dir(), filename) + run_command('cp', src, dest, check : true) endforeach + +# shared_library( +# 'fft2d_with_fftw1d', +# ['fft2d_with_fftw1d.cpp', 'fft2d_with_fftw1d.h'], +# install : true, +# ) diff --git a/plugins/fluidfft-fftw/src/fluidfft_fftw/meson.build b/plugins/fluidfft-fftw/src/fluidfft_fftw/meson.build index 8edbbf9..b3f3729 100644 --- a/plugins/fluidfft-fftw/src/fluidfft_fftw/meson.build +++ b/plugins/fluidfft-fftw/src/fluidfft_fftw/meson.build @@ -7,6 +7,5 @@ py.install_sources( subdir: 'fluidfft-fftw' ) -subdir('fft1d') subdir('fft2d') subdir('fft3d')