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

feat(meson): add meson build option #105

Merged
merged 5 commits into from
Feb 5, 2022
Merged
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
23 changes: 19 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,23 @@ jobs:
pip install https://github.com/modflowpy/flopy/zipball/develop
pip install pylint flake8 black

- name: Run isort
run: |
echo "if isort check fails update isort using"
echo " pip install isort --upgrade"
echo "and run"
echo " isort ./flopy"
echo "and then commit the changes."
isort --verbose --check --diff ./pymake

- name: Run black
run: black --check --line-length 79 ./pymake
run: |
echo "if black check fails update black using"
echo " pip install black --upgrade"
echo "and run"
echo " black ./flopy"
echo "and then commit the changes."
black --check --diff ./pymake

- name: Run flake8
run: flake8 --count --show-source ./pymake
Expand All @@ -56,7 +71,7 @@ jobs:
- name: Checkout pymake repo
uses: actions/[email protected]

- name: Setup Python 3.9
- name: Setup Python
uses: actions/[email protected]
with:
python-version: 3.9
Expand All @@ -68,7 +83,7 @@ jobs:

- name: Base pymake installation
run: |
pip install . --use-feature=in-tree-build
pip --verbose install .

- name: Print pymake version
run: |
Expand Down Expand Up @@ -152,7 +167,7 @@ jobs:
os_script: ifortvars_linux.sh
- os: macos-latest
os_script: ifortvars_macos.sh
- os: windows-latest
- os: windows-2019
os_script: ifortvars_windows.bat
defaults:
run:
Expand Down
15 changes: 8 additions & 7 deletions autotest/ci_setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import shutil

import pymake

temp_pth = "temp"
Expand All @@ -17,7 +18,7 @@ def download_mf6_examples(verbose=False):

# download the modflow 6 release
pm.download_target(target, download_path=temp_pth)
assert pm.download, "could not download {} distribution".format(target)
assert pm.download, f"could not download {target} distribution"

# get program dictionary
prog_dict = pymake.usgs_program_data.get_target(target)
Expand All @@ -26,10 +27,10 @@ def download_mf6_examples(verbose=False):
temp_download_dir = os.path.join(temp_pth, prog_dict.dirname)
temp_dir = os.path.join(temp_download_dir, "examples")

print("copying files to...{}".format(mf6_exdir))
print(f"copying files to...{mf6_exdir}")
shutil.copytree(temp_dir, mf6_exdir)

print("removing...{} directory".format(temp_download_dir))
print(f"removing...{temp_download_dir} directory")
shutil.rmtree(temp_download_dir)

return os.path.abspath(mf6_exdir)
Expand Down Expand Up @@ -64,7 +65,7 @@ def examples_list(verbose=False):
for file_name in fileList:
if file_name.lower() == "mfsim.nam":
if verbose:
print("Found directory: {}".format(dirName))
print(f"Found directory: {dirName}")
src_folders.append(dirName)
src_folders = sorted(src_folders)

Expand All @@ -73,9 +74,9 @@ def examples_list(verbose=False):
for idx, folder in enumerate(src_folders):
if verbose:
if idx == 0:
print("\n\nMODFLOW 6 examples:\n{}".format(78 * "-"))
print("{:>3d}: {}".format(idx + 1, folder))
f.write("{}\n".format(os.path.abspath(folder)))
print(f"\n\nMODFLOW 6 examples:\n{78 * '-'}")
print(f"{idx + 1:>3d}: {folder}")
f.write(f"{os.path.abspath(folder)}\n")
f.close()

return
Expand Down
31 changes: 14 additions & 17 deletions autotest/t001_test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import os
import sys
import shutil
import sys

import pymake
import flopy

import pytest

import pymake

# use the line below to set fortran compiler using environmental variables
# os.environ["FC"] = "ifort"
# os.environ["CC"] = "icc"
Expand Down Expand Up @@ -79,9 +79,7 @@ def run_mf2005(namefile, regression=True):

# run test models
exe_name = os.path.abspath(epth)
msg = "running model...{}".format(testname) + " using {}".format(
exe_name
)
msg = f"running model...{testname}" + f" using {exe_name}"
print(msg)
if os.path.exists(exe_name):
success, buff = flopy.run_model(
Expand All @@ -90,7 +88,7 @@ def run_mf2005(namefile, regression=True):
else:
success = False

assert success, "base model {} ".format(nam) + "did not run."
assert success, f"base model {nam} " + "did not run."

# If it is a regression run, then setup and run the model with the
# release target and the reference target
Expand All @@ -100,9 +98,10 @@ def run_mf2005(namefile, regression=True):
testpth_reg = os.path.join(testpth, testname_reg)
pymake.setup(namefile, testpth_reg)
# exe_name = os.path.abspath(target_previous)
msg = "running regression model...{}".format(
testname_reg
) + " using {}".format(exe_name)
msg = (
"running regression model...{}".format(testname_reg)
+ f" using {exe_name}"
)
print(msg)

if os.path.exists(exe_name):
Expand All @@ -112,9 +111,7 @@ def run_mf2005(namefile, regression=True):
else:
success_reg = False

assert success_reg, (
"regression model {} ".format(nam) + "did not run."
)
assert success_reg, f"regression model {nam} " + "did not run."

# compare results
if success and success_reg:
Expand All @@ -137,10 +134,10 @@ def run_mf2005(namefile, regression=True):
pymake.teardown(testpth)
else:
success = False
errmsg = "could not run...{}".format(os.path.basename(nam))
errmsg = f"could not run...{os.path.basename(nam)}"
else:
success = False
errmsg = "{} does not exist".format(target)
errmsg = f"{target} does not exist"

assert success, errmsg

Expand Down Expand Up @@ -179,13 +176,13 @@ def test_download():

# download the target
pm.download_target(target, download_path=dstpth)
assert pm.download, "could not download {}".format(target)
assert pm.download, f"could not download {target}"


@pytest.mark.base
@pytest.mark.regression
def test_compile():
assert pm.build() == 0, "could not compile {}".format(target)
assert pm.build() == 0, f"could not compile {target}"


@pytest.mark.regression
Expand Down
16 changes: 8 additions & 8 deletions autotest/t002_test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import os
import sys
import shutil
import sys

import pymake
import flopy

import pytest

import pymake

# determine if running on a continuous integration server
is_CI = "CI" in os.environ

Expand Down Expand Up @@ -65,7 +65,7 @@ def edit_namefile(namefile):
for line in lines:
if "global" in line.lower():
continue
f.write("{}\n".format(line))
f.write(f"{line}\n")
f.close()


Expand Down Expand Up @@ -93,7 +93,7 @@ def run_seawat(fn):
success, buff = flopy.run_model(
epth, os.path.basename(fn), model_ws=os.path.dirname(fn), silent=False
)
errmsg = "could not run...{}".format(os.path.basename(fn))
errmsg = f"could not run...{os.path.basename(fn)}"
assert success, errmsg
return

Expand All @@ -119,7 +119,7 @@ def build_seawat_dependency_graphs():
# test that the dependency figure for the SEAWAT main exists
findf = os.path.join(deppth, "swt_v4.f.png")
success = os.path.isfile(findf)
assert success, "could not find {}".format(findf)
assert success, f"could not find {findf}"

assert success, "could not build dependency graphs"

Expand All @@ -135,13 +135,13 @@ def test_download():

# download the target
pm.download_target(target, download_path=dstpth)
assert pm.download, "could not download {}".format(target)
assert pm.download, f"could not download {target}"


@pytest.mark.base
@pytest.mark.regression
def test_compile():
assert pm.build() == 0, "could not compile {}".format(target)
assert pm.build() == 0, f"could not compile {target}"


@pytest.mark.regression
Expand Down
23 changes: 10 additions & 13 deletions autotest/t003_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import os
import sys
import shutil
import pymake
import flopy
import sys

import flopy
import pytest

import pymake

# define program data
target = "mfusg"
if sys.platform.lower() == "win32":
Expand Down Expand Up @@ -53,13 +54,9 @@ def edit_namefile(namefile):
for line in lines:
t = line.split()
fn, ext = os.path.splitext(t[2])
f.write(
"{:15s} {:3s} {} ".format(
t[0], t[1], "{}{}".format(fn, ext.lower())
)
)
f.write(f"{t[0]:15s} {t[1]:3s} {fn}{ext.lower()} ")
if len(t) > 3:
f.write("{}".format(t[3]))
f.write(f"{t[3]}")
f.write("\n")
f.close()

Expand All @@ -85,11 +82,11 @@ def run_mfusg(fn):
# edit namefile
edit_namefile(fn)
# run test models
print("running model...{}".format(os.path.basename(fn)))
print(f"running model...{os.path.basename(fn)}")
success, buff = flopy.run_model(
epth, os.path.basename(fn), model_ws=os.path.dirname(fn), silent=False
)
errmsg = "could not run {}".format(fn)
errmsg = f"could not run {fn}"
assert success, errmsg

return
Expand All @@ -104,13 +101,13 @@ def test_download():

# download the modflow-usg release
pm.download_target(target, download_path=dstpth)
assert pm.download, "could not download {}".format(target)
assert pm.download, f"could not download {target}"


@pytest.mark.base
@pytest.mark.regression
def test_compile():
assert pm.build() == 0, "could not compile {}".format(target)
assert pm.build() == 0, f"could not compile {target}"
return


Expand Down
22 changes: 11 additions & 11 deletions autotest/t004_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
import sys
import shutil
import sys

import flopy
import pytest

import pymake
import flopy

# define program data
target = "mp6"
Expand All @@ -23,7 +23,7 @@
mp6pth = os.path.join(dstpth, prog_dict.dirname)
expth = os.path.join(mp6pth, "example-run")

sim_files = ["EXAMPLE-{}.mpsim".format(n) for n in range(1, 10)]
sim_files = [f"EXAMPLE-{n}.mpsim" for n in range(1, 10)]

exe_name = target
srcpth = os.path.join(mp6pth, prog_dict.srcdir)
Expand All @@ -39,17 +39,17 @@ def update_files(fn):
replace_files = ["example-6", "example-7", "example-8"]
for rf in replace_files:
if rf in fn.lower():
fname1 = os.path.join(expth, "{}.locations".format(rf))
fname2 = os.path.join(expth, "{}_mod.locations".format(rf))
fname1 = os.path.join(expth, f"{rf}.locations")
fname2 = os.path.join(expth, f"{rf}_mod.locations")
print(
"copy {} to {}".format(
os.path.basename(fname1), os.path.basename(fname2)
)
)
shutil.copy(fname1, fname2)
print("deleting {}".format(os.path.basename(fname1)))
print(f"deleting {os.path.basename(fname1)}")
os.remove(fname1)
fname1 = os.path.join(expth, "{}.locations".format(rf.upper()))
fname1 = os.path.join(expth, f"{rf.upper()}.locations")
print(
"renmae {} to {}".format(
os.path.basename(fname2), os.path.basename(fname1)
Expand All @@ -63,7 +63,7 @@ def run_modpath6(fn):
if os.path.exists(epth):
update_files(fn)
# run the model
print("running model...{}".format(fn))
print(f"running model...{fn}")
success, buff = flopy.run_model(epth, fn, model_ws=expth, silent=False)
return success

Expand Down Expand Up @@ -91,19 +91,19 @@ def test_download():
shutil.rmtree(mp6pth)

pm.download_target(target, download_path=dstpth)
assert pm.download, "could not download {} distribution".format(target)
assert pm.download, f"could not download {target} distribution"


@pytest.mark.base
@pytest.mark.regression
def test_compile():
assert pm.build() == 0, "could not compile {}".format(target)
assert pm.build() == 0, f"could not compile {target}"


@pytest.mark.regression
@pytest.mark.parametrize("fn", sim_files)
def test_modpath6(fn):
assert run_modpath6(fn), "could not run {}".format(fn)
assert run_modpath6(fn), f"could not run {fn}"


@pytest.mark.base
Expand Down
Loading