Skip to content

Commit

Permalink
feat(get-modflow): support ARM mac nightly build
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Feb 23, 2024
1 parent 4e6f4c1 commit f7ee396
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions autotest/test_get_modflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
20 changes: 15 additions & 5 deletions flopy/utils/get_modflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f7ee396

Please sign in to comment.