diff --git a/autotest/test_requests.py b/autotest/test_requests.py index c625b10..6785028 100644 --- a/autotest/test_requests.py +++ b/autotest/test_requests.py @@ -103,6 +103,21 @@ def test_latest_assets(): assert key in test_keys, msg +@flaky(max_runs=RERUNS) +@pytest.mark.requests +def test_detected_asset(): + """The asset detected for the current platform must exist in the release.""" + from pymake.utils.download import _get_zipname + + zipname = _get_zipname(None) + assets = pymake.get_repo_assets("MODFLOW-USGS/executables") + print(f"evaluating the availability of...{zipname}") + assert zipname in assets, ( + f"asset ({zipname}) detected for {sys.platform} is not in the release " + f"assets ({', '.join(assets.keys())})" + ) + + @pytest.mark.dependency("previous_assets") @flaky(max_runs=RERUNS) @pytest.mark.requests diff --git a/pymake/utils/download.py b/pymake/utils/download.py index 9ad028d..afb5fe7 100644 --- a/pymake/utils/download.py +++ b/pymake/utils/download.py @@ -14,6 +14,7 @@ """ import os +import platform as _platform import shutil import sys import tarfile @@ -551,8 +552,8 @@ def _get_zipname(platform): ---------- platform : str Platform that will run the executables. Valid values include mac, - linux, win32 and win64. If platform is None, then routine will - download the latest asset from the github repository. + macarm, linux, win32 and win64. If platform is None, then routine + will download the latest asset from the github repository. Returns ------- @@ -562,7 +563,11 @@ def _get_zipname(platform): """ if platform is None: if sys.platform.lower() == "darwin": - platform = "mac" + # only arm64 assets are built for macOS + if _platform.machine().lower() in ("arm64", "aarch64"): + platform = "macarm" + else: + platform = "mac" elif sys.platform.lower().startswith("linux"): platform = "linux" elif "win" in sys.platform.lower(): @@ -576,7 +581,7 @@ def _get_zipname(platform): raise Exception(errmsg) else: msg = f"unknown platform detected ({platform})" - success = platform in ["mac", "linux", "win32", "win64"] + success = platform in ["mac", "macarm", "linux", "win32", "win64"] if not success: raise ValueError(msg) return f"{platform}.zip" @@ -631,7 +636,7 @@ def _get_default_json(tag_name=None): url += f"{tag_name}/" # define asset names and paths for assets - names = ["mac.zip", "linux.zip", "win32.zip", "win64.zip"] + names = ["mac.zip", "macarm.zip", "linux.zip", "win32.zip", "win64.zip"] paths = [url + p for p in names] assets_list = [] @@ -869,8 +874,8 @@ def getmfexes( None the github repo will be queried for the version number. platform : str Platform that will run the executables. Valid values include mac, - linux, win32 and win64. If platform is None, then routine will - download the latest asset from the github repository. + macarm, linux, win32 and win64. If platform is None, then routine + will download the latest asset from the github repository. exes : str or list of strings executable or list of executables to retain verbose : bool @@ -951,8 +956,8 @@ def getmfnightly( Location to put the executables (default is current working directory) platform : str Platform that will run the executables. Valid values include mac, - linux, win32 and win64. If platform is None, then routine will - download the latest asset from the github repository. + macarm, linux, win32 and win64. If platform is None, then routine + will download the latest asset from the github repository. exes : str or list of strings executable or list of executables to retain verbose : bool