Skip to content

Commit

Permalink
Do not fail on unknown platform tags and just print a warning
Browse files Browse the repository at this point in the history
  • Loading branch information
aignas committed Apr 5, 2024
1 parent ed4e8ab commit 5643866
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 7 deletions.
21 changes: 16 additions & 5 deletions python/private/whl_target_platforms.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,11 @@ _CPU_ALIASES = {
"aarch64": "aarch64",
"arm64": "aarch64",
"ppc": "ppc",
"ppc64": "ppc",
"ppc64le": "ppc",
"s390x": "s390x",
"armv6l": "arm",
"armv7l": "arm",
} # buildifier: disable=unsorted-dict-items

_OS_PREFIXES = {
Expand Down Expand Up @@ -249,7 +252,8 @@ def whl_target_platforms(platform_tag, abi_tag = ""):
for cpu in cpus
]

fail("unknown platform_tag os: {}".format(platform_tag))
print("WARNING: ignoring unknown platform_tag os: {}".format(platform_tag)) # buildifier: disable=print
return []

def _cpu_from_tag(tag):
candidate = [
Expand All @@ -262,7 +266,14 @@ def _cpu_from_tag(tag):

if tag == "win32":
return ["x86_32"]
elif tag.endswith("universal2") and tag.startswith("macosx"):
return ["x86_64", "aarch64"]
else:
fail("Unrecognized tag: '{}': cannot determine CPU".format(tag))
elif tag == "win_ia64":
return []
elif tag.startswith("macosx"):
if tag.endswith("universal2"):
return ["x86_64", "aarch64"]
elif tag.endswith("universal"):
return ["x86_64", "aarch64"]
elif tag.endswith("intel"):
return ["x86_32"]

return []
56 changes: 54 additions & 2 deletions tests/private/whl_target_platforms/whl_target_platforms_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,62 @@ def _test_with_abi(env):

_tests.append(_test_with_abi)

def _can_parse_existing_tags(env):
examples = {
"linux_armv6l": 1,
"linux_armv7l": 1,
"macosx_11_12_arm64": 1,
"macosx_11_12_i386": 1,
"macosx_11_12_intel": 1,
"macosx_11_12_universal": 2,
"macosx_11_12_universal2": 2,
"macosx_11_12_x86_64": 1,
"manylinux1_i686": 1,
"manylinux1_x86_64": 1,
"manylinux2010_i686": 1,
"manylinux2010_x86_64": 1,
"manylinux2014_aarch64": 1,
"manylinux2014_armv7l": 1,
"manylinux2014_i686": 1,
"manylinux2014_ppc64": 1,
"manylinux2014_ppc64le": 1,
"manylinux2014_s390x": 1,
"manylinux2014_x86_64": 1,
"manylinux_11_12_aarch64": 1,
"manylinux_11_12_armv7l": 1,
"manylinux_11_12_i686": 1,
"manylinux_11_12_ppc64": 1,
"manylinux_11_12_ppc64le": 1,
"manylinux_11_12_s390x": 1,
"manylinux_11_12_x86_64": 1,
"manylinux_1_2_aarch64": 1,
"manylinux_1_2_x86_64": 1,
"musllinux_11_12_aarch64": 1,
"musllinux_11_12_armv7l": 1,
"musllinux_11_12_i686": 1,
"musllinux_11_12_ppc64le": 1,
"musllinux_11_12_s390x": 1,
"musllinux_11_12_x86_64": 1,
"win32": 1,
"win_amd64": 1,
"win_arm64": 1,
"win_ia64": 0,
}

for major_version in [2, 10, 13]:
for minor_version in [0, 1, 2, 10, 45]:
for give, want_size in examples.items():
give = give.replace("_11_", "_{}_".format(major_version))
give = give.replace("_12_", "_{}_".format(minor_version))
got = whl_target_platforms(give)
env.expect.that_str("{}: {}".format(give, len(got))).equals("{}: {}".format(give, want_size))

_tests.append(_can_parse_existing_tags)

def whl_target_platforms_test_suite(name):
"""Create the test suite.
"""create the test suite.
Args:
args:
name: the name of the test suite
"""
test_suite(name = name, basic_tests = _tests)

0 comments on commit 5643866

Please sign in to comment.