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

feat: add osx-arm64 to platform checks #965

Merged
merged 5 commits into from
Mar 22, 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
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