From 7794d3da8a930fe3426f72cddbf72e638d566018 Mon Sep 17 00:00:00 2001 From: Philip Hyunsu Cho Date: Tue, 27 Aug 2024 18:11:08 -0700 Subject: [PATCH] Ensure that `pip check` does not fail due to bad platform tag (#10755) * Remove custom tag generation * Revert "Remove custom tag generation" This reverts commit fe3cf0e8786c7dc05e1deced3a1c92cd79094735. * Fetch an accurate platform tag from Pip 22+ * Fix formatting * TOML allows trailing commas * Update patch * Add trailing comma * Fix up patch * Use `packaging` Co-authored-by: jakirkham --------- Co-authored-by: jakirkham --- python-package/hatch_build.py | 6 +++--- python-package/pyproject.toml | 5 +++-- tests/buildkite/remove_nccl_dep.patch | 10 ++++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/python-package/hatch_build.py b/python-package/hatch_build.py index 925c917b9..d81a21cd5 100644 --- a/python-package/hatch_build.py +++ b/python-package/hatch_build.py @@ -3,16 +3,16 @@ Custom hook to customize the behavior of Hatchling. Here, we customize the tag of the generated wheels. """ -import sysconfig from typing import Any, Dict from hatchling.builders.hooks.plugin.interface import BuildHookInterface +from packaging.tags import platform_tags def get_tag() -> str: """Get appropriate wheel tag according to system""" - tag_platform = sysconfig.get_platform().replace("-", "_").replace(".", "_") - return f"py3-none-{tag_platform}" + platform_tag = next(platform_tags()) + return f"py3-none-{platform_tag}" class CustomBuildHook(BuildHookInterface): diff --git a/python-package/pyproject.toml b/python-package/pyproject.toml index 4a76b39e1..367f77147 100644 --- a/python-package/pyproject.toml +++ b/python-package/pyproject.toml @@ -1,6 +1,7 @@ [build-system] requires = [ - "hatchling>=1.12.1" + "hatchling>=1.12.1", + "packaging>=21.3", ] backend-path = ["."] build-backend = "packager.pep517" @@ -29,7 +30,7 @@ classifiers = [ dependencies = [ "numpy", "scipy", - "nvidia-nccl-cu12 ; platform_system == 'Linux' and platform_machine != 'aarch64'" + "nvidia-nccl-cu12 ; platform_system == 'Linux' and platform_machine != 'aarch64'", ] [project.urls] diff --git a/tests/buildkite/remove_nccl_dep.patch b/tests/buildkite/remove_nccl_dep.patch index a2a4a5c88..c5a8fe3ac 100644 --- a/tests/buildkite/remove_nccl_dep.patch +++ b/tests/buildkite/remove_nccl_dep.patch @@ -1,14 +1,12 @@ diff --git python-package/pyproject.toml python-package/pyproject.toml -index 8835def25..46c1451c2 100644 +index 20d3f9974..953087ff4 100644 --- python-package/pyproject.toml +++ python-package/pyproject.toml -@@ -30,8 +30,7 @@ classifiers = [ - ] +@@ -30,7 +30,6 @@ classifiers = [ dependencies = [ "numpy", -- "scipy", -- "nvidia-nccl-cu12 ; platform_system == 'Linux' and platform_machine != 'aarch64'" -+ "scipy" + "scipy", +- "nvidia-nccl-cu12 ; platform_system == 'Linux' and platform_machine != 'aarch64'", ] [project.urls]