From 445adac23c513efdfc06890ade2d03d0ab8b885a Mon Sep 17 00:00:00 2001 From: Joseph D Hughes Date: Wed, 5 Jul 2023 16:34:30 -0500 Subject: [PATCH 1/3] refactor(usgsprograms): update triangle and mt3d to use github repos --- pymake/utils/_usgs_src_update.py | 92 +------------------------------- pymake/utils/usgsprograms.txt | 4 +- 2 files changed, 3 insertions(+), 93 deletions(-) diff --git a/pymake/utils/_usgs_src_update.py b/pymake/utils/_usgs_src_update.py index fb9dbd3d..0eb5c36f 100644 --- a/pymake/utils/_usgs_src_update.py +++ b/pymake/utils/_usgs_src_update.py @@ -9,8 +9,6 @@ import types from typing import Union -from .usgsprograms import usgs_program_data - def _get_function_names(module, select_name=None): """Get a dictionary of functions available in a user-specified source file. @@ -111,15 +109,9 @@ def _update_triangle_files(srcdir, fc, cc, arch, double): ------- """ - # move the downloaded files - rootdir = os.path.join(*(srcdir.split(os.path.sep)[:1])) - prog_dict = usgs_program_data().get_target("triangle") - dirname = prog_dict.dirname - dstpth = os.path.join(rootdir, dirname) - # modify long to long long on windows if "win32" in sys.platform.lower() and cc in ("icl", "cl"): - src = os.path.join(rootdir, "triangle.c") + src = os.path.join(srcdir, "triangle.c") with open(src, "r") as f: lines = f.readlines() for idx, line in enumerate(lines): @@ -129,28 +121,6 @@ def _update_triangle_files(srcdir, fc, cc, arch, double): with open(src, "w") as f: for line in lines: f.write(line) - - # make destination directory - if not os.path.exists(dstpth): - os.makedirs(dstpth, exist_ok=True) - - # make src directory - if not os.path.exists(srcdir): - os.makedirs(srcdir) - - # move the source files - src = os.path.join(rootdir, "triangle.c") - dst = os.path.join(srcdir, "triangle.c") - shutil.move(src, dst) - src = os.path.join(rootdir, "triangle.h") - dst = os.path.join(srcdir, "triangle.h") - shutil.move(src, dst) - - # remove remaining downloaded files - for file in os.listdir(rootdir): - src = os.path.join(rootdir, file) - if os.path.isfile(src): - os.remove(src) return @@ -175,66 +145,6 @@ def _update_mt3dms_files(srcdir, fc, cc, arch, double): ------- """ - # move the downloaded files - rootdir = os.path.join(*(srcdir.split(os.path.sep)[:1])) - prog_dict = usgs_program_data().get_target("mt3dms") - dirname = prog_dict.dirname - dstpth = os.path.join(rootdir, dirname) - - # Clean up unneeded files - for f in ["ReadMe_MT3DMS.pdf", "upgrade.pdf"]: - fpth = os.path.join(rootdir, f) - if os.path.isfile(fpth): - print(f'Removing..."{f}"') - os.remove(fpth) - - # remove some unneeded folders - dir_list = ["bin", "doc", "examples", "utility"] - for d in dir_list: - dname = os.path.join(rootdir, d) - if os.path.isdir(dname): - print(f'Removing..."{dname}"') - shutil.rmtree(dname) - - # make destination directory - if not os.path.exists(dstpth): - os.makedirs(dstpth, exist_ok=True) - - # move the files - for src_dir, _, files in os.walk(rootdir): - # skip target directory (dirname) - if dirname in src_dir: - continue - if src_dir is rootdir: - continue - else: - dst_dir = src_dir.replace(rootdir + os.path.sep, "") - dst_dir = os.path.join(dstpth, dst_dir) - if not os.path.exists(dst_dir): - os.mkdir(dst_dir) - for file_ in files: - src_file = os.path.join(src_dir, file_) - dst_file = os.path.join(dst_dir, file_) - if os.path.exists(dst_file): - os.remove(dst_file) - print(f"{src_file} -> {dst_dir}") - # shutil.copy(src_file, dst_dir) - shutil.move(src_file, dst_file) - - # remove the original source directory - dname = os.path.join(rootdir, "src") - if os.path.isdir(dname): - print(f'Removing..."{dname}"') - shutil.rmtree(dname) - - # remove some unneeded files - file_list = ["automake.fig", "mt3dms5b.exe"] - for f in file_list: - dname = os.path.join(srcdir, f) - if os.path.isfile(dname): - print(f'Removing..."{dname}"') - os.remove(dname) - # Replace the getcl command with getarg f1 = open(os.path.join(srcdir, "mt3dms5.for"), "r") f2 = open(os.path.join(srcdir, "mt3dms5.for.tmp"), "w") diff --git a/pymake/utils/usgsprograms.txt b/pymake/utils/usgsprograms.txt index ae63d308..7e8a007e 100644 --- a/pymake/utils/usgsprograms.txt +++ b/pymake/utils/usgsprograms.txt @@ -3,10 +3,10 @@ mf6 , 6.4.2 , True , https://github.com/MODFLOW-USGS/modflow6/releas zbud6 , 6.4.2 , True , https://github.com/MODFLOW-USGS/modflow6/releases/download/6.4.2/mf6.4.2_linux.zip , mf6.4.2_linux , utils/zonebudget/src, True , False , False libmf6 , 6.4.2 , True , https://github.com/MODFLOW-USGS/modflow6/releases/download/6.4.2/mf6.4.2_linux.zip , mf6.4.2_linux , srcbmi , True , False , True mp7 , 7.2.001, True , https://water.usgs.gov/water-resources/software/MODPATH/modpath_7_2_001.zip , modpath_7_2_001 , source , True , False , False -mt3dms , 5.3.0 , True , https://hydro.geo.ua.edu/mt3d/mt3dms_530.exe , mt3dms5.3.0 , src/true-binary , True , False , False +mt3dms , 5.3.0 , True , https://github.com/MODFLOW-USGS/mt3dms/archive/refs/heads/main.zip , mt3dms-main , true-binary , True , False , False mt3dusgs , 1.1.0 , True , https://water.usgs.gov/water-resources/software/MT3D-USGS/mt3dusgs1.1.0.zip , mt3dusgs1.1.0 , src , True , False , False vs2dt , 3.3 , True , https://water.usgs.gov/water-resources/software/VS2DI/vs2dt3_3.zip , vs2dt3_3 , include , True , False , False -triangle , 1.6 , True , https://www.netlib.org/voronoi/triangle.zip , triangle1.6 , src , True , False , False +triangle , 1.6 , True , https://github.com/MODFLOW-USGS/triangle/archive/refs/heads/main.zip , triangle-main , src , True , False , False gridgen , 1.0.02 , True , https://water.usgs.gov/water-resources/software/GRIDGEN/gridgen.1.0.02.zip , gridgen.1.0.02 , src , True , False , False crt , 1.3.1 , True , https://water.usgs.gov/ogw/CRT/CRT_1.3.1.zip , CRT_1.3.1 , SOURCE , True , False , False sutra , 3.0 , True , https://water.usgs.gov/water-resources/software/sutra/SUTRA_3_0_0.zip , SutraSuite , SUTRA_3_0/source , True , False , False From 254996ea2af3c8d69c3c2d0be000abfb99545c13 Mon Sep 17 00:00:00 2001 From: Joseph D Hughes Date: Wed, 5 Jul 2023 16:53:54 -0500 Subject: [PATCH 2/3] * add flaky to test_cli_cmds::test_make_program --- autotest/test_cli_cmds.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autotest/test_cli_cmds.py b/autotest/test_cli_cmds.py index 5b2ecd6e..95dc8ca7 100644 --- a/autotest/test_cli_cmds.py +++ b/autotest/test_cli_cmds.py @@ -4,6 +4,9 @@ import subprocess import pytest +from flaky import flaky + +RERUNS = 3 targets = ( "triangle", @@ -47,6 +50,7 @@ def clean_up() -> None: @pytest.mark.dependency(name="make_program") @pytest.mark.base +@flaky(max_runs=RERUNS) @pytest.mark.parametrize("target", targets) def test_make_program(target: str) -> None: cmd = [ From 79f1a225d18eedcc5c2a7ca0d8dc06c32e1970ca Mon Sep 17 00:00:00 2001 From: Joseph D Hughes Date: Wed, 5 Jul 2023 17:02:39 -0500 Subject: [PATCH 3/3] * use triangle and mt3dms GitHub releases --- pymake/utils/usgsprograms.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymake/utils/usgsprograms.txt b/pymake/utils/usgsprograms.txt index 7e8a007e..698b861c 100644 --- a/pymake/utils/usgsprograms.txt +++ b/pymake/utils/usgsprograms.txt @@ -3,10 +3,10 @@ mf6 , 6.4.2 , True , https://github.com/MODFLOW-USGS/modflow6/releas zbud6 , 6.4.2 , True , https://github.com/MODFLOW-USGS/modflow6/releases/download/6.4.2/mf6.4.2_linux.zip , mf6.4.2_linux , utils/zonebudget/src, True , False , False libmf6 , 6.4.2 , True , https://github.com/MODFLOW-USGS/modflow6/releases/download/6.4.2/mf6.4.2_linux.zip , mf6.4.2_linux , srcbmi , True , False , True mp7 , 7.2.001, True , https://water.usgs.gov/water-resources/software/MODPATH/modpath_7_2_001.zip , modpath_7_2_001 , source , True , False , False -mt3dms , 5.3.0 , True , https://github.com/MODFLOW-USGS/mt3dms/archive/refs/heads/main.zip , mt3dms-main , true-binary , True , False , False +mt3dms , 5.3.0 , True , https://github.com/MODFLOW-USGS/mt3dms/releases/download/2.0/mt3dms-2.0.zip , mt3dms-2.0 , true-binary , True , False , False mt3dusgs , 1.1.0 , True , https://water.usgs.gov/water-resources/software/MT3D-USGS/mt3dusgs1.1.0.zip , mt3dusgs1.1.0 , src , True , False , False vs2dt , 3.3 , True , https://water.usgs.gov/water-resources/software/VS2DI/vs2dt3_3.zip , vs2dt3_3 , include , True , False , False -triangle , 1.6 , True , https://github.com/MODFLOW-USGS/triangle/archive/refs/heads/main.zip , triangle-main , src , True , False , False +triangle , 1.6 , True , https://github.com/MODFLOW-USGS/triangle/releases/download/1.0/triangle-1.0.zip , triangle-1.0 , src , True , False , False gridgen , 1.0.02 , True , https://water.usgs.gov/water-resources/software/GRIDGEN/gridgen.1.0.02.zip , gridgen.1.0.02 , src , True , False , False crt , 1.3.1 , True , https://water.usgs.gov/ogw/CRT/CRT_1.3.1.zip , CRT_1.3.1 , SOURCE , True , False , False sutra , 3.0 , True , https://water.usgs.gov/water-resources/software/sutra/SUTRA_3_0_0.zip , SutraSuite , SUTRA_3_0/source , True , False , False