Skip to content

Commit

Permalink
Unset LDFLAGS and CMAKE_PREFIX_PATH variables
Browse files Browse the repository at this point in the history
CABLE is linked against incorrect libraries for netcdf and MPI when
running benchcab (v4.0.2) from the hh5 conda environment. The issue is
due to environment variables being set which affect the behaviour of the
build, notably LDFLAGS and CMAKE_PREFIX_PATH, which point CMake to find
the netcdf and MPI libraries installed in the current conda environment.
This change unsets these variables so that CMake finds the appropriate
libraries which get loaded in as modules.

Fixes #279
  • Loading branch information
SeanBryan51 committed Apr 17, 2024
1 parent 8ca400f commit 95bbab1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/benchcab/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ def build(self, modules: list[str], mpi=False):
[internal.CMAKE_MODULE, *modules]
):
env = os.environ.copy()

# This is required to prevent CMake from finding the conda
# installation of netcdf-fortran (#279):
env.pop("LDFLAGS", None)

Check warning on line 135 in src/benchcab/model.py

View check run for this annotation

Codecov / codecov/patch

src/benchcab/model.py#L135

Added line #L135 was not covered by tests

# This is required to prevent CMake from finding MPI libraries in
# the conda environment (#279):
env.pop("CMAKE_PREFIX_PATH", None)

Check warning on line 139 in src/benchcab/model.py

View check run for this annotation

Codecov / codecov/patch

src/benchcab/model.py#L139

Added line #L139 was not covered by tests

# This is required so that the netcdf-fortran library is discoverable by
# pkg-config:
prepend_path(
Expand Down

0 comments on commit 95bbab1

Please sign in to comment.