Skip to content

Commit

Permalink
should find ip_4 lib in more directories
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyCera-NOAA committed Jul 3, 2024
1 parent a16cd94 commit 5a5533a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Install python dependencies via pip
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
python -m pip install --upgrade setuptools setuptools_scm meson-python
python -m pip install --upgrade wheel
python -m pip install $(grep numpy requirements.txt)
python -m pip install pytest
Expand Down
47 changes: 43 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ project('grib2io_interp',
'warning_level=3',
'buildtype=release',
])

fs = import('fs')

fc = meson.get_compiler('fortran')
cc = meson.get_compiler('c')

Expand Down Expand Up @@ -45,8 +48,44 @@ prefix = run_command(py,
['-c', 'import sys; print(sys.prefix)'],
check : false
).stdout().strip()
link_lib = cc.find_library('ip_4', static: false, required: true, dirs: prefix / 'lib')
incdir_ip = prefix / 'include_4'

search_dirs = [
prefix,
'/usr' / 'local',
'/sw',
'/opt',
'/opt' / 'local',
'/opt' / 'homebrew',
'/usr',
]

# Need to constrain this array to only directories that exist.
# That is what cc.find_library(..., header_include_directories: ip4_inc_dirs, ...) expects.
ip4_inc_dirs = []
ip4_inc_dirs_str = []
foreach d : search_dirs
if fs.is_dir(d / 'include_4')
ip4_inc_dirs += include_directories(d / 'include_4')
ip4_inc_dirs_str += d / 'include_4'
endif
endforeach

# Do that same thing for the lib directories, however, this works fine
# unfiltered in cc.find_library(..., dirs: lib_dirs, ...)
lib_dirs = []
foreach d : search_dirs
if fs.is_dir(d / 'lib')
lib_dirs += d / 'lib'
endif
endforeach

ip4_link_lib = cc.find_library('ip_4',
static: false,
required: true,
dirs: lib_dirs,
has_headers: ['iplib.h'],
header_include_directories: ip4_inc_dirs,
)

ftn_sources = [
'src' / 'interpolate' / 'interpolate.f90'
Expand All @@ -65,14 +104,14 @@ grib2io_interp_source = custom_target('interpolatemodule',
'--lower',
])

inc_np = include_directories(incdir_numpy, incdir_f2py, incdir_ip)
inc_np = include_directories(incdir_numpy, incdir_f2py, ip4_inc_dirs_str)

py.extension_module('interpolate',
ftn_sources,
fortranobject_c,
grib2io_interp_source,
include_directories: inc_np,
dependencies : [py_dep, link_lib, quadmath_dep, omp_dep],
dependencies : [py_dep, ip4_link_lib, quadmath_dep, omp_dep],
install : true,
subdir: 'grib2io_interp'
)
Expand Down

0 comments on commit 5a5533a

Please sign in to comment.