-
Notifications
You must be signed in to change notification settings - Fork 6
/
whl_build.py
executable file
·59 lines (47 loc) · 1.4 KB
/
whl_build.py
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
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
import argparse
import glob
import os
import sys
import subprocess
import tomllib
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("project")
parser.add_argument("--config", default="packages.toml")
args = parser.parse_args()
with open(args.config, "rb") as fp:
cfg = tomllib.load(fp)
try:
pkgdata = cfg["packages"][args.project]
version = pkgdata["version"]
except KeyError:
parser.error(f"{args.project} not found in {args.config}")
env = os.environ.copy()
env["PATH"] = f"{env['PATH']}:/build/venv/build/bin"
if "environment" in pkgdata:
env.update(pkgdata["environment"])
pipargs = [
sys.executable,
"-m",
"pip",
"--disable-pip-version-check",
"-v",
"wheel",
"--no-build-isolation",
"--no-deps",
"--no-binary",
":all:",
"-w",
"dist",
]
if "pip_args" in pkgdata:
pipargs += pkgdata["pip_args"]
pipargs.append(f"{args.project}=={version}")
result = subprocess.run(pipargs, env=env)
# Sets variable for use in github actions
if result.returncode == 0:
project_cvt = args.project.replace("-", "_")
for f in glob.glob(f"dist/{project_cvt}-{version}-*.whl"):
print(f"::set-output name=wheel::{f}")
exit(result.returncode)