From 4c5e2ee3ec6699f61acb04a5e7bd35407b16f9ff Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Mon, 19 Feb 2024 12:52:01 -0500 Subject: [PATCH] feat(get-modflow): support ARM mac distributions (#2110) --- autotest/test_get_modflow.py | 3 ++- flopy/utils/get_modflow.py | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/autotest/test_get_modflow.py b/autotest/test_get_modflow.py index ca161a04d7..b06b8cdb24 100644 --- a/autotest/test_get_modflow.py +++ b/autotest/test_get_modflow.py @@ -119,7 +119,6 @@ def test_get_release(repo): tag = "latest" release = get_release(repo=repo, tag=tag) assets = release["assets"] - expected_assets = ["linux.zip", "mac.zip", "win64.zip"] expected_ostags = [a.replace(".zip", "") for a in expected_assets] actual_assets = [asset["name"] for asset in assets] @@ -129,6 +128,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..77bbc268ed 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 @@ -60,7 +61,7 @@ def get_ostag() -> str: elif sys.platform.startswith("win"): return "win" + ("64" if sys.maxsize > 2**32 else "32") elif sys.platform.startswith("darwin"): - return "mac" + return "macarm" if processor() == "arm" else "mac" raise ValueError(f"platform {sys.platform!r} not supported") @@ -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(