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

tags: accept mac tags without minor versions #579

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions packaging/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,16 @@ def mac_platforms(
compat_version = major_version, 0
binary_formats = _mac_binary_formats(compat_version, arch)
for binary_format in binary_formats:
yield "macosx_{major}_{minor}_{binary_format}".format(
major=major_version, minor=0, binary_format=binary_format
yield "macosx_{major}_{binary_format}".format(
major=major_version, binary_format=binary_format
)
# Mac OS 11 and 12 seem to omit the minor version, we will keep

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is going to be confusing, see #578 (comment)

# them for backwards compatibility and avoid generating tags
# with it in the future
if major_version <= 12:
yield "macosx_{major}_{minor}_{binary_format}".format(
major=major_version, minor=0, binary_format=binary_format
)

if version >= (11, 0):
# Mac OS 11 on x86_64 is compatible with binaries from previous releases.
Expand Down
41 changes: 37 additions & 4 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,11 @@ def test_version_detection(self, monkeypatch):
if (major, minor) == ("10", "16"):
print(platforms, "macosx_11+")
# For 10.16, the real version is at least 11.0.
prefix, major, minor, _ = platforms[0].split("_", maxsplit=3)
prefix, major, _ = platforms[0].split("_", maxsplit=2)
assert prefix == "macosx"
assert int(major) >= 11
assert minor == "0"
else:
expected = f"macosx_{major}_{minor}_"
expected = f"macosx_{major}_"
print(platforms, expected)
assert platforms[0].startswith(expected)

Expand Down Expand Up @@ -303,14 +302,20 @@ def test_mac_platforms(self):

assert not list(tags.mac_platforms((10, 0), "x86_64"))

@pytest.mark.parametrize("major,minor", [(11, 0), (11, 3), (12, 0), (12, 3)])
@pytest.mark.parametrize(
"major,minor", [(11, 0), (11, 3), (12, 0), (12, 3), (13, 0)]
)
def test_macos_11(self, major, minor):
platforms = list(tags.mac_platforms((major, minor), "x86_64"))
assert "macosx_11_0_arm64" not in platforms
assert "macosx_11_0_x86_64" in platforms
assert "macosx_11_3_x86_64" not in platforms
assert "macosx_11_0_universal" in platforms
assert "macosx_11_0_universal2" in platforms
assert "macosx_11_arm64" not in platforms
assert "macosx_11_x86_64" in platforms
assert "macosx_11_universal" in platforms
assert "macosx_11_universal2" in platforms
# Mac OS "10.16" is the version number that binaries compiled against an old
# (pre 11.0) SDK will see. It can also be enabled explicitly for a process
# with the environment variable SYSTEM_VERSION_COMPAT=1.
Expand All @@ -319,10 +324,22 @@ def test_macos_11(self, major, minor):
assert "macosx_10_15_universal2" in platforms
assert "macosx_10_4_x86_64" in platforms
assert "macosx_10_3_x86_64" not in platforms
assert "macosx_10_x86_64" not in platforms
assert "macosx_10_universal2" not in platforms
if major >= 12:
assert "macosx_12_0_x86_64" in platforms
assert "macosx_12_0_universal" in platforms
assert "macosx_12_0_universal2" in platforms
assert "macosx_12_x86_64" in platforms
assert "macosx_12_universal" in platforms
assert "macosx_12_universal2" in platforms
if major >= 13:
assert "macosx_13_0_x86_64" not in platforms
assert "macosx_13_0_universal" not in platforms
assert "macosx_13_0_universal2" not in platforms
assert "macosx_13_x86_64" in platforms
assert "macosx_13_universal" in platforms
assert "macosx_13_universal2" in platforms

platforms = list(tags.mac_platforms((major, minor), "arm64"))
assert "macosx_11_0_arm64" in platforms
Expand All @@ -333,9 +350,21 @@ def test_macos_11(self, major, minor):
assert "macosx_10_15_x86_64" not in platforms
assert "macosx_10_4_x86_64" not in platforms
assert "macosx_10_3_x86_64" not in platforms
assert "macosx_11_arm64" in platforms
assert "macosx_11_universal" not in platforms
assert "macosx_11_universal2" in platforms
assert "macosx_10_universal2" not in platforms
assert "macosx_10_x86_64" not in platforms
if major >= 12:
assert "macosx_12_0_arm64" in platforms
assert "macosx_12_0_universal2" in platforms
assert "macosx_12_arm64" in platforms
assert "macosx_12_universal2" in platforms
if major >= 13:
assert "macosx_13_0_arm64" not in platforms
assert "macosx_13_0_universal2" not in platforms
assert "macosx_13_arm64" in platforms
assert "macosx_13_universal2" in platforms


class TestManylinuxPlatform:
Expand Down Expand Up @@ -1041,6 +1070,10 @@ def teardown_method(self):
# Clear the version cache
tags._glibc_version = []

def test_interpreter_platform(self):
tag = sysconfig.get_platform().replace("-", "_").replace(".", "_")
assert tag in list(tags.platform_tags())

@pytest.mark.parametrize(
"name,expected",
[("CPython", "cp"), ("PyPy", "pp"), ("Jython", "jy"), ("IronPython", "ip")],
Expand Down