Skip to content

Commit 57d0862

Browse files
authored
fix(get-modflow): fix code.json handling (#1641)
* fix(get-modflow): fix subsets * fix(get-modflow): don't depend on modflow6 dist folder name
1 parent 869787a commit 57d0862

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

autotest/test_get_modflow.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"executables": [
3434
"crt",
3535
"gridgen",
36-
"gsflow",
3736
"mf2000",
3837
"mf2005",
3938
"mf2005dbl",
@@ -140,7 +139,7 @@ def test_select_bindir(bindir, tmpdir):
140139
pytest.skip(f"{expected_path} is not writable")
141140
selected = select_bindir(f":{bindir}")
142141

143-
if system() != 'Darwin':
142+
if system() != "Darwin":
144143
assert selected == expected_path
145144
else:
146145
# for some reason sys.prefix can return different python
@@ -162,6 +161,7 @@ def test_script_help():
162161

163162
@flaky
164163
@requires_github
164+
@pytest.mark.slow
165165
def test_script_options(tmpdir, downloads_dir):
166166
bindir = tmpdir / "bin1"
167167
assert not bindir.exists()
@@ -213,7 +213,7 @@ def test_script_options(tmpdir, downloads_dir):
213213
pytest.skip(f"GitHub {rate_limit_msg}")
214214
assert len(stderr) == returncode == 0
215215
files = [item.stem for item in bindir.iterdir() if item.is_file()]
216-
assert sorted(files) == ["mfnwt", "mfnwtdbl", "mp6"]
216+
assert sorted(files) == ["mfnwt", "mp6"]
217217

218218
# similar as before, but also specify a ostag
219219
bindir = tmpdir / "bin3"
@@ -234,11 +234,12 @@ def test_script_options(tmpdir, downloads_dir):
234234
pytest.skip(f"GitHub {rate_limit_msg}")
235235
assert len(stderr) == returncode == 0
236236
files = [item.name for item in bindir.iterdir() if item.is_file()]
237-
assert sorted(files) == ["mfnwt.exe", "mfnwtdbl.exe"]
237+
assert sorted(files) == ["mfnwt.exe"]
238238

239239

240240
@flaky
241241
@requires_github
242+
@pytest.mark.slow
242243
@pytest.mark.parametrize("repo", repo_options.keys())
243244
def test_script(tmpdir, repo, downloads_dir):
244245
bindir = str(tmpdir)
@@ -260,6 +261,7 @@ def test_script(tmpdir, repo, downloads_dir):
260261

261262
@flaky
262263
@requires_github
264+
@pytest.mark.slow
263265
@pytest.mark.parametrize("repo", repo_options.keys())
264266
def test_python_api(tmpdir, repo, downloads_dir):
265267
bindir = str(tmpdir)

flopy/utils/get_modflow.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def get_release(repo, tag="latest", quiet=False) -> dict:
179179
release = json.loads(result.decode())
180180
tag_name = release["tag_name"]
181181
if not quiet:
182-
print(f"fetched release {tag_name!r} from {owner}/{repo}")
182+
print(f"fetched release {tag_name!r} info from {owner}/{repo}")
183183

184184
return release
185185

@@ -444,14 +444,24 @@ def run_main(
444444
)
445445
else:
446446
if not quiet:
447-
print(f"downloading to '{download_pth}'")
447+
print(f"downloading '{download_url}' to '{download_pth}'")
448448
urllib.request.urlretrieve(download_url, download_pth)
449449

450450
if subset:
451451
if isinstance(subset, str):
452452
subset = set(subset.replace(",", " ").split())
453453
elif not isinstance(subset, set):
454454
subset = set(subset)
455+
subset = set(
456+
[
457+
(
458+
f"{e}{lib_suffix}"
459+
if e.startswith("lib")
460+
else f"{e}{exe_suffix}"
461+
)
462+
for e in subset
463+
]
464+
)
455465

456466
# Open archive and extract files
457467
extract = set()
@@ -475,10 +485,10 @@ def run_main(
475485
with zipfile.ZipFile(download_pth, "r") as zipf:
476486
if repo == "modflow6":
477487
# modflow6 release contains the whole repo with an internal bindir
478-
inner_bin = asset_stem + "/bin"
479488
for pth in zipf.namelist():
480-
if pth.startswith(inner_bin) and not pth.endswith("bin/"):
481-
full_path[Path(pth).name] = pth
489+
p = Path(pth)
490+
if p.parent.name == "bin":
491+
full_path[p.name] = pth
482492
files = set(full_path.keys())
483493
else:
484494
# assume all files to be extracted

0 commit comments

Comments
 (0)