xgboost/python-package/hatch_build.py
Philip Hyunsu Cho 7794d3da8a
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 <jakirkham@gmail.com>

---------

Co-authored-by: jakirkham <jakirkham@gmail.com>
2024-08-27 18:11:08 -07:00

24 lines
667 B
Python

"""
Custom hook to customize the behavior of Hatchling.
Here, we customize the tag of the generated wheels.
"""
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"""
platform_tag = next(platform_tags())
return f"py3-none-{platform_tag}"
class CustomBuildHook(BuildHookInterface):
"""A custom build hook"""
def initialize(self, version: str, build_data: Dict[str, Any]) -> None:
"""This step ccurs immediately before each build."""
build_data["tag"] = get_tag()