-
Notifications
You must be signed in to change notification settings - Fork 0
/
BootstrapEpilog.py
61 lines (54 loc) · 1.61 KB
/
BootstrapEpilog.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
# ----------------------------------------------------------------------
# |
# | BootstrapEpilog.py
# |
# | David Brownell <db@DavidBrownell.com>
# | 2023-12-18 15:26:50
# |
# ----------------------------------------------------------------------
# |
# | Copyright David Brownell 2023-24
# | Distributed under the MIT License.
# |
# ----------------------------------------------------------------------
import os
import subprocess
import sys
from pathlib import Path
# Parse the arguments
is_debug = False
is_force = False
is_verbose = False
is_package = False
no_cache = False
display_flags: list[str] = []
for arg in sys.argv[
2:
]: # First arg is the script name, second arg is the name of the shell script to write to
if arg == "--debug":
is_debug = True
elif arg == "--force":
is_force = True
elif arg == "--verbose":
is_verbose = True
elif arg == "--package":
is_package = True
display_flags.append("package")
elif arg == "--no-cache":
no_cache = True
else:
raise Exception("Unrecognized argument: {}".format(arg))
if is_debug:
is_verbose = True
subprocess.run(
'pip install --disable-pip-version-check {} --editable ".[dev{}]"'.format(
"--no-cache-dir" if no_cache else "",
", package" if is_package else "",
),
check=True,
shell=True,
)
with (
Path(__file__).parent / os.environ["PYTHON_BOOTSTRAPPER_GENERATED_DIR"] / "bootstrap_flags.json"
).open("w") as f:
f.write("[{}]".format(", ".join(f'"{flag}"' for flag in display_flags)))