Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(get-modflow): support ARM macs by default (previously opt-in) #2225

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions autotest/test_get_modflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,16 @@ 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_assets = ["linux.zip", "mac.zip", "macarm.zip", "win64.zip"]
expected_ostags = [a.replace(".zip", "") for a in expected_assets]
actual_assets = [asset["name"] for asset in assets]

if repo == "modflow6":
# can remove if modflow6 releases follow asset name conventions followed in executables and nightly build repos
# can remove if modflow6 releases follow the same asset name
# convention used in the executables and nightly build repos
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 All @@ -142,15 +140,13 @@ def test_select_bindir(bindir, function_tmpdir):
pytest.skip(f"{expected_path} is not writable")
selected = select_bindir(f":{bindir}")

# For some reason sys.prefix can return different python
# installs when invoked here and get_modflow.py on macOS.
# Work around by just comparing the end of the bin path,
# should be .../Python.framework/Versions/<version>/bin
if system() != "Darwin":
assert selected == expected_path
else:
# for some reason sys.prefix can return different python
# installs when invoked here and get_modflow.py on macOS
# https://github.com/modflowpy/flopy/actions/runs/3331965840/jobs/5512345032#step:8:1835
#
# work around by just comparing the end of the bin path
# should be .../Python.framework/Versions/<version>/bin
assert selected.parts[-4:] == expected_path.parts[-4:]


Expand Down
15 changes: 3 additions & 12 deletions flopy/utils/get_modflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ 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"
arch = processor()
return "mac" + (arch if arch == "arm" else "")
raise ValueError(f"platform {sys.platform!r} not supported")


Expand Down Expand Up @@ -407,19 +408,9 @@ 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:
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(
Expand Down Expand Up @@ -608,7 +599,7 @@ def add_item(key, fname, do_chmod):
break
shutil.rmtree(str(bindir_path))

if ostag in ["linux", "mac", "macarm"]:
if "win" not in ostag:
# similar to "chmod +x fname" for each executable
for fname in chmod:
pth = bindir / fname
Expand Down
Loading