-
Notifications
You must be signed in to change notification settings - Fork 82
/
build_binaries.py
66 lines (62 loc) · 1.86 KB
/
build_binaries.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
60
61
62
63
64
65
66
# Standard Library
import argparse
import os
import subprocess
import sys
parser = argparse.ArgumentParser(description="Build smdebug binaries")
parser.add_argument(
"--upload",
default=False,
dest="upload",
action="store_true",
help="Pass --upload if you want to upload the binaries" "built to the s3 location",
)
parser.add_argument(
"--replace-latest",
default=False,
dest="replace_latest",
action="store_true",
help="Pass --replace-latest if you want to upload the new binary to "
"replace the latest binary in the S3 location. Note that"
"this also requires you to pass --upload",
)
parser.add_argument("--s3-prefix", default="s3://smdebug-binaries/")
args = parser.parse_args()
exec(open("smdebug/_version.py").read())
VERSION = __version__
subprocess.check_call([sys.executable, "setup.py", "bdist_wheel", "--universal"])
path = "smdebug"
if args.upload:
subprocess.check_call(
[
"aws",
"s3",
"cp",
"dist/smdebug-{}-py2.py3-none-any.whl".format(VERSION),
os.path.join(args.s3_prefix, path, ""),
]
)
if args.replace_latest:
# upload current version
subprocess.check_call(
[
"aws",
"s3",
"cp",
os.path.join(args.s3_prefix, path, f"smdebug-{VERSION}-py2.py3-none-any.whl"),
os.path.join(args.s3_prefix, path, "latest", ""),
]
)
# remove other versions
subprocess.check_call(
[
"aws",
"s3",
"rm",
"--recursive",
"--exclude",
f"smdebug-{VERSION}*",
os.path.join(args.s3_prefix, path, "latest"),
]
)
subprocess.check_call(["rm", "-rf", "dist", "build", "*.egg-info", ".eggs"])