Skip to content

Commit

Permalink
feat: add osx-arm64 to platform checks (#965)
Browse files Browse the repository at this point in the history
add osx-arm64 to platforms and only build if additional platform is
configured
  • Loading branch information
aliciaaevans authored Mar 22, 2024
1 parent d5a80c9 commit 9f6df10
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
5 changes: 4 additions & 1 deletion bioconda_utils/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
6 changes: 5 additions & 1 deletion bioconda_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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):
Expand Down
23 changes: 23 additions & 0 deletions test/test_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:',
Expand Down
31 changes: 28 additions & 3 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"""
Expand All @@ -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
Expand Down

0 comments on commit 9f6df10

Please sign in to comment.