-
Notifications
You must be signed in to change notification settings - Fork 0
/
BootstrapEpilog.py
38 lines (30 loc) · 978 Bytes
/
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
# pylint: disable=missing-module-docstring
import os
import subprocess
import sys
from pathlib import Path
# Parse the arguments
is_package = False
no_cache = False
display_flags: list[str] = []
# First arg is the script name, second arg is the name of the shell script to write to
for arg in sys.argv[2:]:
if arg == "--package":
is_package = True
display_flags.append("package")
elif arg == "--no-cache":
no_cache = True
else:
sys.stderr.write(f"WARNING: '{arg}' is not a recognized argument.\n")
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)))