From f7ee396af6f3499e9dbd183c9050f40bac16479d Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Thu, 22 Feb 2024 21:10:11 -0500 Subject: [PATCH] feat(get-modflow): support ARM mac nightly build --- autotest/test_get_modflow.py | 2 ++ flopy/utils/get_modflow.py | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/autotest/test_get_modflow.py b/autotest/test_get_modflow.py index 3228dce218..bd5e9cfcce 100644 --- a/autotest/test_get_modflow.py +++ b/autotest/test_get_modflow.py @@ -126,6 +126,8 @@ def test_get_release(repo): assert {a.rpartition("_")[2] for a in actual_assets} >= { a for a in expected_assets if not a.startswith("win") } + elif repo == "modflow6-nightly-build": + expected_assets.append("macarm.zip") else: for ostag in expected_ostags: assert any( diff --git a/flopy/utils/get_modflow.py b/flopy/utils/get_modflow.py index 54c2a7d12c..5cb84e1e71 100755 --- a/flopy/utils/get_modflow.py +++ b/flopy/utils/get_modflow.py @@ -18,6 +18,7 @@ import zipfile from importlib.util import find_spec from pathlib import Path +from platform import processor __all__ = ["run_main"] __license__ = "CC0" @@ -33,7 +34,7 @@ "modflow6-nightly-build": "modflow6_nightly", } available_repos = list(renamed_prefix.keys()) -available_ostags = ["linux", "mac", "win32", "win64"] +available_ostags = ["linux", "mac", "macarm", "win32", "win64"] max_http_tries = 3 # Check if this is running from flopy @@ -69,7 +70,7 @@ def get_suffixes(ostag) -> Tuple[str, str]: return ".exe", ".dll" elif ostag == "linux": return "", ".so" - elif ostag == "mac": + elif "mac" in ostag: return "", ".dylib" else: raise KeyError( @@ -405,16 +406,25 @@ def run_main( # get the selected release release = get_release(owner, repo, release_id, quiet) assets = release.get("assets", []) - + asset_names = [a["name"] for a in assets] for asset in assets: - if ostag in asset["name"]: + asset_name = asset["name"] + if ostag in asset_name: + # temporary hack for nightly gfortran build for ARM macs + # todo: clean up if/when all repos have an ARM mac build + if ( + repo == "modflow6-nightly-build" + and "macarm.zip" in asset_names + and processor() == "arm" + and ostag == "mac.zip" + ): + continue break else: raise ValueError( f"could not find ostag {ostag!r} from release {release['tag_name']!r}; " f"see available assets here:\n{release['html_url']}" ) - asset_name = asset["name"] download_url = asset["browser_download_url"] if repo == "modflow6": asset_pth = Path(asset_name)