Skip to content

Commit

Permalink
Improve platform tag documentation and warnings
Browse files Browse the repository at this point in the history
Add relevant architecture to the deceptive tag warning.
  • Loading branch information
HexDecimal committed Jul 19, 2024
1 parent 1561977 commit 382b090
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions delocate/delocating.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,25 +858,31 @@ def _calculate_minimum_wheel_name(
# Wheel platform tags MUST use the macOS release version, not the literal
# version provided by macOS. Since macOS 11 the minor version number is not
# part of the macOS release version and MUST be zero for tagging purposes.
def get_release_version(version: Version) -> str:
"""Return the macOS release version from the given actual version."""
def get_macos_platform_tag(version: Version, architecture: str) -> str:
"""Return the macOS platform tag for this version and architecture.
`version` will be converted to a release version expected by pip.
"""
if require_target_macos_version is not None:
# Version was specified explicitly with MACOSX_DEPLOYMENT_TARGET.
version = max(version, require_target_macos_version)
elif version.major >= 11 and version.minor > 0:
# Warn when the platform tag is given a deceptive version number.
# This is the range where an automatic version is deceptive.
logger.warning(
"Wheel will be tagged as supporting macOS %i,"
"Wheel will be tagged as supporting macOS %i (%s),"
" but will not support macOS versions older than %i.%i\n\t"
"Configure MACOSX_DEPLOYMENT_TARGET to suppress this warning.",
version.major,
architecture,
version.major,
version.minor,
)

return f"{version.major}_{0 if version.major >= 11 else version.minor}"
minor: Final = 0 if version.major >= 11 else version.minor
return f"macosx_{version.major}_{minor}_{architecture}"

platform_tag: Final = ".".join(
f"macosx_{get_release_version(version)}_{arch}"
get_macos_platform_tag(version, arch)
for arch, version in _pack_architectures(arch_version).items()
)
prefix: Final = wheel_name.rsplit("-", 1)[0]
Expand Down
2 changes: 1 addition & 1 deletion delocate/tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ def test_delocate_wheel_macos_release_version_warning(
["delocate-wheel", plat_wheel.whl, "-vv"], check=True
)

assert "will be tagged as supporting macOS 12" in result.stderr
assert "will be tagged as supporting macOS 12 (x86_64)" in result.stderr
assert "will not support macOS versions older than 12.1" in result.stderr

# Should create a 12.0 wheel instead of 12.1
Expand Down

0 comments on commit 382b090

Please sign in to comment.