-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up Meson build for a single Fortran component
This is WIP, but the project files are in the right place.
- Loading branch information
Showing
2 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
project('{{ cookiecutter.package_name }}', '{{ cookiecutter.language }}', 'cython', version: '{{ cookiecutter.package_version }}') | ||
|
||
py = import('python').find_installation(pure: false) | ||
fc = meson.get_compiler('fortran') | ||
|
||
python_inc = py.get_path('data') / 'include' | ||
numpy_inc = run_command( | ||
py, | ||
[ | ||
'-c', | ||
'import numpy; print(numpy.get_include())' | ||
], | ||
check: true | ||
).stdout().strip() | ||
incs = include_directories( | ||
[ | ||
'{{ cookiecutter.package_name }}/lib', | ||
python_inc, | ||
numpy_inc, | ||
] | ||
) | ||
|
||
deps = [ | ||
fc.find_library('bmif'), | ||
fc.find_library('heatf'), | ||
fc.find_library('bmiheatf'), | ||
] | ||
|
||
{# This is temporary until I figure out how to do multiple components. #} | ||
{%- set babelized_class = 'HeatModelF' -%} | ||
|
||
srcs = [ | ||
'{{ cookiecutter.package_name }}/lib/bmi_interoperability.f90', | ||
'{{ cookiecutter.package_name }}/lib/{{ babelized_class|lower }}.pyx', | ||
] | ||
|
||
# Files get copied to <python directory>/site-packages/<subdir> | ||
install_pkg_srcs = [ | ||
'{{ cookiecutter.package_name }}/__init__.py', | ||
'{{ cookiecutter.package_name }}/_bmi.py', | ||
] | ||
py.install_sources( | ||
install_pkg_srcs, | ||
subdir: '{{ cookiecutter.package_name }}', | ||
) | ||
install_lib_srcs = [ | ||
'{{ cookiecutter.package_name }}/lib/__init__.py', | ||
'{{ cookiecutter.package_name }}/lib/{{ babelized_class|lower }}.pyx', | ||
] | ||
py.install_sources( | ||
install_lib_srcs, | ||
subdir: '{{ cookiecutter.package_name }}/lib', | ||
) | ||
|
||
install_subdir( | ||
'meta/{{ babelized_class }}', | ||
install_dir: py.get_install_dir() / '{{ cookiecutter.package_name }}/data', | ||
) | ||
|
||
py.extension_module( | ||
'{{ babelized_class|lower }}', | ||
srcs, | ||
dependencies: deps, | ||
include_directories: incs, | ||
install: true, | ||
subdir: '{{ cookiecutter.package_name }}/lib', | ||
) | ||
|
||
# This is a temporary fix for editable installs. | ||
run_command('cp', '-r', '{{ cookiecutter.package_name }}/data', 'build') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters