Skip to content

Commit 76187c0

Browse files
authored
Cleanup PyPI variant script. (#11294)
1 parent 8bd70dd commit 76187c0

File tree

3 files changed

+14
-26
lines changed

3 files changed

+14
-26
lines changed

ops/script/pypi_variants.py

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33
import argparse
44
import os
55

6-
from test_utils import PY_PACKAGE, ROOT
6+
from test_utils import PY_PACKAGE
77

88
IN_PATH = os.path.join(PY_PACKAGE, "pyproject.toml.in")
99
OUT_PATH = os.path.join(PY_PACKAGE, "pyproject.toml")
1010

11-
WHL_CPU = """
12-
[tool.hatch.build.targets.wheel]
13-
packages = ["xgboost/"]
14-
"""
15-
1611
CHOICES = ["default", "cpu", "manylinux2014"]
1712

1813

14+
NCCL_WHL = """ \"nvidia-nccl-cu12 ; platform_system == 'Linux' and platform_machine != 'aarch64'\","""
15+
16+
NAME = "{{ name }}"
17+
NCCL = "{{ nccl }}"
18+
19+
1920
def copyfile(src: str, dst: str) -> None:
2021
with open(src, "rb") as fd:
2122
content = fd.read()
@@ -33,28 +34,13 @@ def make_pyproject(variant: str) -> None:
3334
readme_cpu = os.path.join(PY_PACKAGE, "README.cpu.rst")
3435
readme = os.path.join(PY_PACKAGE, "README.rst")
3536
if variant == "cpu":
36-
pyproject = (
37-
pyproject.replace("{{ name }}", "xgboost-cpu")
38-
.replace("{{ wheel }}", WHL_CPU)
39-
.replace("{{ nccl }}", "")
40-
)
37+
pyproject = pyproject.replace(NAME, "xgboost-cpu").replace(NCCL, "")
4138
copyfile(readme_cpu, readme)
4239
elif variant == "manylinux2014":
43-
pyproject = (
44-
pyproject.replace("{{ name }}", "xgboost")
45-
.replace("{{ wheel }}", "")
46-
.replace("{{ nccl }}", "")
47-
)
40+
pyproject = pyproject.replace(NAME, "xgboost").replace(NCCL, "")
4841
copyfile(readme_dft, readme)
4942
else:
50-
pyproject = (
51-
pyproject.replace("{{ name }}", "xgboost")
52-
.replace("{{ wheel }}", "")
53-
.replace(
54-
"{{ nccl }}",
55-
""" \"nvidia-nccl-cu12 ; platform_system == 'Linux' and platform_machine != 'aarch64'\",""",
56-
)
57-
)
43+
pyproject = pyproject.replace(NAME, "xgboost").replace(NCCL, NCCL_WHL)
5844
copyfile(readme_dft, readme)
5945
pyproject = (
6046
f"# Generated by `{os.path.basename(__file__)}`, don't edit.\n" + pyproject

python-package/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ disable = [
7373
dummy-variables-rgx = "(unused|)_.*"
7474
reports = false
7575

76-
76+
[tool.hatch.build.targets.wheel]
77+
packages = ["xgboost/"]
7778

7879
[tool.pylint.basic]
7980
# Enforce naming convention

python-package/pyproject.toml.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ disable = [
7272
dummy-variables-rgx = "(unused|)_.*"
7373
reports = false
7474

75-
{{ wheel }}
75+
[tool.hatch.build.targets.wheel]
76+
packages = ["xgboost/"]
7677

7778
[tool.pylint.basic]
7879
# Enforce naming convention

0 commit comments

Comments
 (0)