From 9f6df10bfecd048956acc80e7bb3d57952585529 Mon Sep 17 00:00:00 2001 From: "Alicia A. Evans" <108547992+aliciaaevans@users.noreply.github.com> Date: Fri, 22 Mar 2024 18:36:00 -0400 Subject: [PATCH] feat: add osx-arm64 to platform checks (#965) add osx-arm64 to platforms and only build if additional platform is configured --- bioconda_utils/build.py | 5 ++++- bioconda_utils/utils.py | 6 +++++- test/test_recipe.py | 23 +++++++++++++++++++++++ test/test_utils.py | 31 ++++++++++++++++++++++++++++--- 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/bioconda_utils/build.py b/bioconda_utils/build.py index 92f7b0ae3e..ec17e963cf 100644 --- a/bioconda_utils/build.py +++ b/bioconda_utils/build.py @@ -277,10 +277,13 @@ def do_not_consider_for_additional_platform(recipe_folder: str, recipe: str, pla Return True if current native platform are not included in recipe's additional platforms (no need to build). """ recipe_obj = _recipe.Recipe.from_file(recipe_folder, recipe) - # On linux-aarch64 env, only build recipe with linux-aarch64 extra_additional_platforms + # On linux-aarch64 or osx-arm64 env, only build recipe with matching extra_additional_platforms if platform == "linux-aarch64": if "linux-aarch64" not in recipe_obj.extra_additional_platforms: return True + if platform == "osx-arm64": + if "osx-arm64" not in recipe_obj.extra_additional_platforms: + return True return False diff --git a/bioconda_utils/utils.py b/bioconda_utils/utils.py index 2e3277ecb7..cc6be6ec09 100644 --- a/bioconda_utils/utils.py +++ b/bioconda_utils/utils.py @@ -1520,6 +1520,8 @@ def native_platform(): return "linux-aarch64" if sys.platform.startswith("linux"): return "linux" + if sys.platform.startswith("darwin") and arch == "arm64": + return "osx-arm64" if sys.platform.startswith("darwin"): return "osx" raise ValueError("Running on unsupported platform") @@ -1532,11 +1534,13 @@ def platform2subdir(platform): return 'linux-aarch64' elif platform == 'osx': return 'osx-64' + elif platform == 'osx-arm64': + return 'osx-arm64' elif platform == 'noarch': return 'noarch' else: raise ValueError( - 'Unsupported platform: bioconda only supports linux, linux-aarch64, osx and noarch.') + 'Unsupported platform: bioconda only supports linux, linux-aarch64, osx, osx-arm64 and noarch.') def get_versions(self, name): diff --git a/test/test_recipe.py b/test/test_recipe.py index 5e1b84559c..e3822ce7a9 100644 --- a/test/test_recipe.py +++ b/test/test_recipe.py @@ -260,6 +260,29 @@ def test_recipe_package_names(recipe): @with_recipes def test_recipe_extra_additional_platforms(recipe): + assert recipe.extra_additional_platforms == [] + recipe.meta_yaml += [ + 'extra:', + ' additional-platforms:', + ' - linux-aarch64', + ' - osx-arm64' + ] + recipe.render() + assert recipe.extra_additional_platforms == ["linux-aarch64", "osx-arm64"] + +@with_recipes +def test_recipe_extra_additional_platform_osx(recipe): + assert recipe.extra_additional_platforms == [] + recipe.meta_yaml += [ + 'extra:', + ' additional-platforms:', + ' - osx-arm64' + ] + recipe.render() + assert recipe.extra_additional_platforms == ["osx-arm64"] + +@with_recipes +def test_recipe_extra_additional_platform_linux(recipe): assert recipe.extra_additional_platforms == [] recipe.meta_yaml += [ 'extra:', diff --git a/test/test_utils.py b/test/test_utils.py index 855252f0d5..12524ee3d8 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -939,10 +939,18 @@ def test_native_platform_skipping(): # Don't skip linux-x86 for any recipes ["one", "linux", False], ["two", "linux", False], - # Skip recipe without linux aarch64 enable on linux-aarch64 platform + ["three", "linux", False], + ["four", "linux", False], + # Skip recipes without linux aarch64 enable on linux-aarch64 platform ["one", "linux-aarch64", True], - # Don't skip recipe with linux aarch64 enable on linux-aarch64 platform + ["three", "linux-aarch64", True], + # Don't skip recipes with linux aarch64 enable on linux-aarch64 platform ["two", "linux-aarch64", False], + ["four", "linux-aarch64", False], + ["one", "osx-arm64", True], + ["two", "osx-arm64", True], + ["three", "osx-arm64", False], + ["four", "osx-arm64", False], ] r = Recipes( """ @@ -954,11 +962,28 @@ def test_native_platform_skipping(): two: meta.yaml: | package: - name: one + name: two + version: "0.1" + extra: + additional-platforms: + - linux-aarch64 + three: + meta.yaml: | + package: + name: three + version: "0.1" + extra: + additional-platforms: + - osx-arm64 + four: + meta.yaml: | + package: + name: four version: "0.1" extra: additional-platforms: - linux-aarch64 + - osx-arm64 """, from_string=True) r.write_recipes() # Make sure RepoData singleton init