-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_wheel.py
More file actions
48 lines (38 loc) · 1.15 KB
/
build_wheel.py
File metadata and controls
48 lines (38 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""Build a platform-specific wheel for ``gbp-stack``.
Reads the target platform tag from the ``GBP_STACK_TARGET_PLATFORM`` env
var (set by the CI workflow) and retags the freshly built wheel with that
tag so PyPI serves the right wheel to each OS/arch.
"""
from __future__ import annotations
import os
import shutil
import subprocess
import sys
from pathlib import Path
def main() -> int:
plat = os.environ.get("GBP_STACK_TARGET_PLATFORM")
here = Path(__file__).parent.resolve()
dist = here / "dist"
if dist.exists():
shutil.rmtree(dist)
cmd = [sys.executable, "-m", "build", "--wheel", "--outdir", str(dist)]
print(">", " ".join(cmd))
rc = subprocess.call(cmd, cwd=here)
if rc != 0:
return rc
if not plat:
return 0
for whl in dist.glob("*.whl"):
retag = [
sys.executable, "-m", "wheel", "tags",
"--platform-tag", plat,
"--remove",
str(whl),
]
print(">", " ".join(retag))
rc = subprocess.call(retag, cwd=here)
if rc != 0:
return rc
return 0
if __name__ == "__main__":
raise SystemExit(main())