forked from robotpy/roborio-wheels
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhl_build.py
executable file
·53 lines (43 loc) · 1.22 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
#!/usr/bin/env python3
import argparse
import glob
import os
import sys
import subprocess
import toml
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) as fp:
cfg = toml.load(fp)
try:
pkgdata = cfg["packages"][args.project]
version = pkgdata["version"]
except KeyError:
parser.error(f"{args.project} not found in {args.config}")
env = None
if "environment" in pkgdata:
env = os.environ.copy()
env.update(pkgdata["environment"])
pipargs = [
sys.executable,
"-m",
"pip",
"--disable-pip-version-check",
"-v",
"wheel",
"--no-binary",
":all:",
"-w",
"dist",
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)