-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeson.build
More file actions
46 lines (38 loc) · 1.54 KB
/
Copy pathmeson.build
File metadata and controls
46 lines (38 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# I don't know why this is needed, as I define the most relevant info in the
# pyproject.toml file
project('pyDISORT', 'c',
meson_version: '>=1.5.0',
)
# Tell meson that it needs to find a FORTRAN compiler
add_languages('fortran')
# Tell meson to find the correct Python installation
py_mod = import('python')
py = py_mod.find_installation(pure: false)
py_dep = py.dependency()
# Do the f2py module build
run_command(py, '-m numpy.f2py *.f -m disort')
# Tell meson that it needs to know about numpy (I don't know why this is
# necessary, but the numpy docs suggest it is)
incdir_numpy = run_command(py,
['-c', 'import os; os.chdir(".."); import numpy; print(numpy.get_include())'],
check : true
).stdout().strip()
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)
# Tell meson what .f files are needed for its build
disort_source = custom_target('disortmodule.c',
input : ['BDREF.f', 'DISOBRDF.f', 'DISORT.f', 'ERRPACK.f', 'LAPACK.f', 'LINPAK.f', 'RDI1MACH.f'],
output : ['disortmodule.c', 'disort-f2pywrappers.f'],
command : [py, '-m', 'numpy.f2py', '@INPUT@', '-m', 'disort', '--lower']
)
# Tell meson to compile the .f files into a .so file
py.extension_module('disort',
['BDREF.f', 'DISOBRDF.f', 'DISORT.f', 'ERRPACK.f', 'LAPACK.f', 'LINPAK.f', 'RDI1MACH.f', disort_source],
incdir_f2py / 'fortranobject.c',
include_directories: inc_np,
dependencies : py_dep,
install : true,
)