Skip to content
Draft
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
20 changes: 16 additions & 4 deletions src/poetry_plugin_bundle/utils/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,24 @@ def create_supported_manylinux_platforms(platform: str) -> list[str]:

For now, only GLIBCMAJOR "2" is supported. It is unclear if there will be a need to support a future major
version like "3" and if specified, how generate the compatible 2.x version tags.

The legacy aliases (manylinux1, manylinux2010, manylinux2014) are included as well, since wheels may be
tagged with only the alias. See https://peps.python.org/pep-0600/#legacy-manylinux-tags
"""
# Implementation based on https://peps.python.org/pep-0600/#package-installers

tag = normalize_legacy_manylinux_alias(platform)

parsed = PlatformTagParseResult.parse(tag)
return [
f"{parsed.platform}_{parsed.version_major}_{tag_minor}_{parsed.arch}"
for tag_minor in range(parsed.version_minor, -1, -1)
]
platforms: list[str] = []
for tag_minor in range(parsed.version_minor, -1, -1):
glibc_tag = f"{parsed.platform}_{parsed.version_major}_{tag_minor}"
platforms.append(f"{glibc_tag}_{parsed.arch}")
# A legacy alias ranks just below the tag for the same glibc version.
legacy_alias = LEGACY_MANYLINUX_ALIASES_BY_GLIBC_TAG.get(glibc_tag)
if legacy_alias:
platforms.append(f"{legacy_alias}_{parsed.arch}")
return platforms


LEGACY_MANYLINUX_ALIASES = {
Expand All @@ -115,6 +123,10 @@ def create_supported_manylinux_platforms(platform: str) -> list[str]:
"manylinux2014": "manylinux_2_17",
}

LEGACY_MANYLINUX_ALIASES_BY_GLIBC_TAG = {
glibc_tag: alias for alias, glibc_tag in LEGACY_MANYLINUX_ALIASES.items()
}


def normalize_legacy_manylinux_alias(tag: str) -> str:
tag_os_index_end = tag.index("_")
Expand Down
37 changes: 37 additions & 0 deletions tests/utils/test_platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ def test_create_supported_tags_legacy_manylinux_aliases() -> None:
python_version_info=(3, 10, 2),
expected_tags={
"cp310-cp310-manylinux_2_5_x86_64",
"cp310-cp310-manylinux1_x86_64",
"cp310-cp310-manylinux_2_1_x86_64",
},
unexpected_tags={
"cp310-cp310-manylinux_2_6_x86_64",
"cp310-cp310-manylinux2010_x86_64",
},
)

Expand All @@ -66,10 +68,13 @@ def test_create_supported_tags_legacy_manylinux_aliases() -> None:
python_version_info=(3, 10, 2),
expected_tags={
"cp310-cp310-manylinux_2_12_x86_64",
"cp310-cp310-manylinux2010_x86_64",
"cp310-cp310-manylinux1_x86_64",
"cp310-cp310-manylinux_2_1_x86_64",
},
unexpected_tags={
"cp310-cp310-manylinux_2_13_x86_64",
"cp310-cp310-manylinux2014_x86_64",
},
)

Expand All @@ -78,6 +83,9 @@ def test_create_supported_tags_legacy_manylinux_aliases() -> None:
python_version_info=(3, 11, 9),
expected_tags={
"cp311-cp311-manylinux_2_17_x86_64",
"cp311-cp311-manylinux2014_x86_64",
"cp311-cp311-manylinux2010_x86_64",
"cp311-cp311-manylinux1_x86_64",
"cp311-cp311-manylinux_2_1_x86_64",
},
unexpected_tags={
Expand All @@ -86,6 +94,35 @@ def test_create_supported_tags_legacy_manylinux_aliases() -> None:
)


def test_create_supported_tags_manylinux_includes_legacy_aliases() -> None:
_test_create_supported_tags(
platform="manylinux_2_34_aarch64",
python_version_info=(3, 14, 0),
expected_tags={
"cp314-cp314-manylinux_2_34_aarch64",
"cp314-cp314-manylinux_2_17_aarch64",
"cp314-cp314-manylinux2014_aarch64",
"cp314-abi3-manylinux2014_aarch64",
"py3-none-manylinux2014_aarch64",
},
unexpected_tags={
"cp314-cp314-manylinux_2_35_aarch64",
},
)


def test_create_supported_tags_ranks_legacy_alias_with_its_glibc_version() -> None:
env = MockEnv(version_info=(3, 14, 0))
tags = [
str(tag)
for tag in platforms.create_supported_tags("manylinux_2_34_aarch64", env)
]

index = tags.index("cp314-cp314-manylinux2014_aarch64")
assert tags[index - 1] == "cp314-cp314-manylinux_2_17_aarch64"
assert tags[index + 1] == "cp314-cp314-manylinux_2_16_aarch64"


def test_create_supported_tags_macosx() -> None:
_test_create_supported_tags(
platform="macosx_11_0_arm64",
Expand Down
Loading