Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update(meson): make meson the default build tool #182

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ jobs:
run: |
pixi run autotest-Windows

- name: Scheduled job test
if: ${{ github.event_name == 'schedule' }}
run: |
pixi run build-all

- name: Upload failed test output
if: failure()
uses: actions/upload-artifact@v4
with:
name: failed-${{ runner.os }}-intel
path: ./autotest/.failed


- name: Print coverage report before upload
run: |
pixi run coverage-report
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/pymake-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ jobs:
run: |
pixi run autotest-Windows

- name: Scheduled job test
if: ${{ github.event_name == 'schedule' }}
run: |
pixi run build-all

- name: Upload failed test output
if: failure()
uses: actions/upload-artifact@v4
with:
name: failed-${{ runner.os }}-gcc
path: ./autotest/.failed


- name: Print coverage report before upload
run: |
pixi run coverage-report
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ target/

# files in the autotest directory
autotest/temp*/
autotest/.failed/
autotest/*.json
autotest/code.md
mod_temp/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ python mymf6script.py -fc ifort -cc icc

When pymake is installed, a `make-program` (or `make-program.exe` for Windows) program is installed. `make-program` can
be used to build MODFLOW 6, MODFLOW-2005, MODFLOW-NWT, MODFLOW-USG, MODFLOW-LGR, MODFLOW-2000, MODPATH 6, MODPATH 7,
GSFLOW, VS2DT, MT3DMS, MT3D-USGS, SEAWAT, and SUTRA. Utility programs CRT, Triangle, and GRIDGEN can also
GSFLOW, VS2DT, MT3DMS, MT3D-USGS, and SEAWAT. Utility programs CRT, Triangle, and GRIDGEN can also
be built. `make-program` downloads the distribution file (requires an internet connection), unzips the file, sets the
pymake settings required to build the program, and compiles the program from the source files. Optional pymake command
line arguments can be used to customize the build (`-fc`, `-cc`, `--fflags`, etc.). For example, MODFLOW 6 could be
Expand Down
2 changes: 0 additions & 2 deletions autotest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import pytest

# import modflow-devtools fixtures

pytest_plugins = ["modflow_devtools.fixtures"]


Expand Down
1 change: 1 addition & 0 deletions autotest/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ markers =
regression: regression tests
requests: usgsprograms requests tests
schedule: tests to run if a scheduled job
slow: tests taking more than a few seconds to complete
54 changes: 28 additions & 26 deletions autotest/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
]
test_ostag = get_ostag()
test_fc_env = os.environ.get("FC")
if "win" in test_ostag:
meson_exclude = ("mt3dms", "vs2dt", "triangle", "gridgen", "sutra")
elif "win" not in test_ostag and test_fc_env in ("ifort",):
meson_exclude = ("mf2000", "mf2005", "swtv4", "mflgr", "sutra")
else:
meson_exclude = ("sutra",)
meson_exclude = tuple()
# if "win" in test_ostag:
# meson_exclude = ("mt3dms", "vs2dt", "triangle", "gridgen")
# elif "win" not in test_ostag and test_fc_env in ("ifort",):
# meson_exclude = ("mf2000", "mf2005", "swtv4", "mflgr")
# else:
# meson_exclude = tuple()
targets_meson = [t for t in targets if t not in meson_exclude]


Expand Down Expand Up @@ -61,26 +62,6 @@ def build_with_makefile(target, path, fc):
return success, errmsg


@pytest.mark.base
@flaky(max_runs=RERUNS)
@pytest.mark.parametrize("target", targets)
def test_build(function_tmpdir, target: str) -> None:
with set_dir(function_tmpdir):
pm = pymake.Pymake(verbose=True)
pm.target = target
pm.inplace = True
fc = os.environ.get("FC", "gfortran")
assert (
pymake.build_apps(
target,
pm,
verbose=True,
clean=False,
)
== 0
), f"could not compile {target}"


@pytest.mark.base
@flaky(max_runs=RERUNS)
@pytest.mark.parametrize("target", targets_meson)
Expand Down Expand Up @@ -121,3 +102,24 @@ def test_makefile_build(function_tmpdir, target: str) -> None:

success, errmsg = build_with_makefile(target, function_tmpdir, pm.fc)
assert success, errmsg


@pytest.mark.base
@flaky(max_runs=RERUNS)
@pytest.mark.parametrize("target", targets)
def test_build(function_tmpdir, target: str) -> None:
with set_dir(function_tmpdir):
pm = pymake.Pymake(verbose=True)
pm.target = target
pm.inplace = True
fc = os.environ.get("FC", "gfortran")
assert (
pymake.build_apps(
target,
pm,
verbose=True,
clean=False,
meson=False,
)
== 0
), f"could not compile {target}"
89 changes: 54 additions & 35 deletions autotest/test_cli_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@

import pytest
from flaky import flaky
from modflow_devtools.misc import set_dir, set_env
from modflow_devtools.misc import set_dir

from pymake import linker_update_environment
import pymake

RERUNS = 3

targets = (
TARGETS = (
"triangle",
"crt",
)

meson_parm = (
MESON_PARM = (
True,
False,
)

TARGETS_ALL = pymake.usgs_program_data.get_keys(current=True)


def run_cli_cmd(cmd: list) -> None:
process = subprocess.Popen(
Expand All @@ -44,51 +46,68 @@ def run_cli_cmd(cmd: list) -> None:
@flaky(max_runs=RERUNS)
@pytest.mark.dependency(name="make_program")
@pytest.mark.base
@pytest.mark.parametrize("target", targets)
@pytest.mark.parametrize("target", TARGETS)
def test_make_program(function_tmpdir, target: str) -> None:
cmd = [
"make-program",
target,
"--appdir",
str(function_tmpdir),
"--verbose",
]
run_cli_cmd(cmd)
with set_dir(function_tmpdir):
cmd = [
"make-program",
target,
"--appdir",
str(function_tmpdir),
"--verbose",
]
run_cli_cmd(cmd)


@flaky(max_runs=RERUNS)
@pytest.mark.dependency(name="make_program")
@pytest.mark.dependency(name="make_program_mf2005")
@pytest.mark.base
def test_make_program_double(function_tmpdir) -> None:
cmd = [
"make-program",
"mf2005",
"--double",
"--verbose",
"--appdir",
str(function_tmpdir),
]
run_cli_cmd(cmd)
with set_dir(function_tmpdir):
cmd = [
"make-program",
"mf2005",
"--double",
"--verbose",
"--appdir",
str(function_tmpdir),
]
run_cli_cmd(cmd)


@pytest.mark.dependency(name="make_program_all")
@pytest.mark.schedule
def test_make_program_all(module_tmpdir) -> None:
cmd = [
"make-program",
":",
"--appdir",
str(module_tmpdir / "all"),
"--verbose",
"--dryrun",
]
run_cli_cmd(cmd)
def test_make_program_all(function_tmpdir) -> None:
with set_dir(function_tmpdir):
cmd = [
"make-program",
":",
"--appdir",
str(function_tmpdir),
"--verbose",
]
run_cli_cmd(cmd)


@pytest.mark.dependency(name="make_program_all_parametrize")
@pytest.mark.schedule
@pytest.mark.parametrize("target", TARGETS_ALL)
def test_make_program_all_parametrize(function_tmpdir, target: str) -> None:
with set_dir(function_tmpdir):
cmd = [
"make-program",
target,
"--appdir",
str(function_tmpdir),
"--verbose",
]
run_cli_cmd(cmd)


@flaky(max_runs=RERUNS)
@pytest.mark.dependency(name="mfpymake")
@pytest.mark.base
@pytest.mark.parametrize("meson", meson_parm)
@pytest.mark.parametrize("meson", MESON_PARM)
def test_mfpymake(function_tmpdir, meson: bool) -> None:
with set_dir(function_tmpdir):
src = (
Expand Down Expand Up @@ -116,7 +135,7 @@ def test_mfpymake(function_tmpdir, meson: bool) -> None:
fc = os.environ.get("FC")
cmd.append(fc)

linker_update_environment(fc=fc)
pymake.linker_update_environment(fc=fc)

if meson:
cmd.append("--meson")
Expand Down
49 changes: 21 additions & 28 deletions autotest/test_gridgen.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import pathlib as pl
import subprocess
from os import environ
from platform import system

import pytest
from modflow_devtools.misc import set_dir

import pymake

Expand All @@ -22,20 +23,7 @@ def prog_data(target) -> dict:

@pytest.fixture(scope="module")
def workspace(module_tmpdir, prog_data) -> pl.Path:
return module_tmpdir / prog_data.dirname


@pytest.fixture(scope="module")
def pm(module_tmpdir, target) -> pymake.Pymake:
pm = pymake.Pymake(verbose=True)
pm.target = str(target)
pm.appdir = str(module_tmpdir)
pm.cc = environ.get("CXX", "g++")
pm.fc = None
pm.inplace = True
pm.makeclean = True
yield pm
pm.finalize()
return module_tmpdir / f"temp/{prog_data.dirname}"


def run_command(args, cwd):
Expand All @@ -58,17 +46,22 @@ def run_gridgen(cmd, ws, exe):
return run_command(args, ws) == 0


@pytest.mark.dependency(name="download")
@pytest.mark.base
def test_download(pm, module_tmpdir, target):
pm.download_target(target, download_path=module_tmpdir)
assert pm.download, f"could not download {target} distribution"


@pytest.mark.dependency(name="build", depends=["download"])
@pytest.mark.base
def test_compile(pm, target):
assert pm.build() == 0, f"could not compile {target}"
@pytest.mark.dependency(name="build")
@pytest.mark.regression
def test_compile(module_tmpdir, target):
cc = os.environ.get("CC", "g++")
fc = None
pymake.linker_update_environment(cc=cc, fc=fc)
with set_dir(module_tmpdir):
assert (
pymake.build_apps(
target.stem,
verbose=True,
clean=False,
meson=True,
)
== 0
), f"could not compile {target.stem}"


@pytest.mark.dependency(name="test", depends=["build"])
Expand All @@ -89,7 +82,7 @@ def test_compile(pm, target):
"grid02qtg-to-vtkfilesv action05_vtkfile.dfn",
],
)
def test_gridgen(cmd, workspace, target):
def test_gridgen(module_tmpdir, cmd, workspace, target):
assert run_gridgen(
cmd, workspace / "examples" / "biscayne", target
cmd, workspace / "examples" / "biscayne", module_tmpdir / target
), f"could not run {cmd}"
Loading
Loading