diff --git a/scripts/addons_core/bl_pkg/cli/blender_ext.py b/scripts/addons_core/bl_pkg/cli/blender_ext.py index 4573c1d3b3e..4935c0a0da3 100755 --- a/scripts/addons_core/bl_pkg/cli/blender_ext.py +++ b/scripts/addons_core/bl_pkg/cli/blender_ext.py @@ -2133,7 +2133,7 @@ def platform_from_this_system() -> str: ) -def blender_platform_from_wheel_platform(wheel_platform: str) -> str: +def blender_platforms_from_wheel_platform(wheel_platform: str) -> list[str]: """ Convert a wheel to a Blender compatible platform: e.g. - ``linux_x86_64`` -> ``linux-x64``. @@ -2142,13 +2142,14 @@ def blender_platform_from_wheel_platform(wheel_platform: str) -> str: - ``win_amd64`` -> ``windows-x64``. - ``macosx_11_0_arm64`` -> ``macos-arm64``. - ``manylinux2014_x86_64`` -> ``linux-x64``. + - ``macosx_10_9_universal2`` -> ``macos-x64``, ``macos-arm64``. """ i = wheel_platform.find("_") if i == -1: # WARNING: this should never or almost never happen. # Return the result as we don't have a better alternative. - return wheel_platform + return [wheel_platform] head = wheel_platform[:i] tail = wheel_platform[i + 1:] @@ -2175,15 +2176,21 @@ def blender_platform_from_wheel_platform(wheel_platform: str) -> str: # (only `x86_64` at the moment). tail = tail.rpartition("_")[2] - return "{:s}-{:s}".format(head, tail) + if (head == "macos") and (tail == "universal2"): + tails = ["x64", "arm64"] + else: + tails = [tail] + + return ["{:s}-{:s}".format(head, tail) for tail in tails] def blender_platform_compatible_with_wheel_platform(platform: str, wheel_platform: str) -> bool: assert platform if wheel_platform == "any": return True - platform_blender = blender_platform_from_wheel_platform(wheel_platform) - return platform == platform_blender + platforms_blender = blender_platforms_from_wheel_platform(wheel_platform) + + return platform in platforms_blender def blender_platform_compatible_with_wheel_platform_from_filepath(platform: str, wheel_filepath: str) -> bool: diff --git a/scripts/addons_core/bl_pkg/tests/test_cli.py b/scripts/addons_core/bl_pkg/tests/test_cli.py index 2caad1a5dbf..46f085eef31 100644 --- a/scripts/addons_core/bl_pkg/tests/test_cli.py +++ b/scripts/addons_core/bl_pkg/tests/test_cli.py @@ -368,13 +368,22 @@ class TestCLI_Build(unittest.TestCase): wheels = [ # Must be included in all packages. "my_portable_package-3.0.1-py3-none-any.whl", + # Each package must include only one. - "my_platform_package-10.3.0-cp311-cp311-macosx_11_0_arm64.whl", - "my_platform_package-10.3.0-cp311-cp311-macosx_11_0_x86_64.whl", - "my_platform_package-10.3.0-cp311-cp311-manylinux_2_28_aarch64.whl", - "my_platform_package-10.3.0-cp311-cp311-manylinux_2_28_x86_64.whl", - "my_platform_package-10.3.0-cp311-cp311-win_amd64.whl", - "my_platform_package-10.3.0-cp311-cp311-win_arm64.whl", + # Include two versions (B may be a "universal" package) for platforms that support it. + "my_platform_package_A-10.3.0-cp311-cp311-macosx_11_0_arm64.whl", + "my_platform_package_A-10.3.0-cp311-cp311-macosx_11_0_x86_64.whl", + "my_platform_package_B-10.3.0-cp311-cp311-macosx_11_0_universal2.whl", + + "my_platform_package_A-10.3.0-cp311-cp311-manylinux_2_28_aarch64.whl", + "my_platform_package_B-10.3.0-cp311-cp311-manylinux_2_28_aarch64.whl", + "my_platform_package_A-10.3.0-cp311-cp311-manylinux_2_28_x86_64.whl", + "my_platform_package_B-10.3.0-cp311-cp311-manylinux_2_28_x86_64.whl", + + "my_platform_package_A-10.3.0-cp311-cp311-win_amd64.whl", + "my_platform_package_B-10.3.0-cp311-cp311-win_amd64.whl", + "my_platform_package_A-10.3.0-cp311-cp311-win_arm64.whl", + "my_platform_package_B-10.3.0-cp311-cp311-win_arm64.whl", ] pkg_idname = "my_test" @@ -431,8 +440,8 @@ class TestCLI_Build(unittest.TestCase): filename = "{:s}-{:s}{:s}".format(pkg_idname, platform.replace("-", "_"), PKG_EXT) value = packages_dict.get(filename) assert isinstance(value, list) - # A check here that gives a better error would be nice, for now, check there are always 4 files. - self.assertEqual(len(value), 4) + # A check here that gives a better error would be nice, for now, check there are always 5 files. + self.assertEqual(len(value), 5) manifest_dict = manifest_dict_from_archive(os.path.join(self.dirpath, filename))