Skip to content

Commit bc6b24b

Browse files
committed
Simplify bootstrapping
1 parent a59066c commit bc6b24b

File tree

1 file changed

+7
-89
lines changed

1 file changed

+7
-89
lines changed

Diff for: bench_runner/templates/workflow_bootstrap.py

+7-89
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# the error message that the version of Python is too old.
77

88

9-
import argparse
109
from pathlib import Path
1110
import shutil
1211
import subprocess
@@ -54,102 +53,21 @@ def install_requirements(venv: Path) -> None:
5453
run_in_venv(venv, "pip", ["install", "-r", "requirements.txt"])
5554

5655

57-
def _main(
58-
fork: str,
59-
ref: str,
60-
machine: str,
61-
benchmarks: str,
62-
flags: str,
63-
force: bool,
64-
pgo: bool,
65-
perf: bool,
66-
pystats: bool,
67-
force_32bit: bool,
68-
run_id: str | None = None,
69-
):
70-
if force_32bit and sys.platform != "win32":
71-
raise RuntimeError("32-bit builds are only supported on Windows")
72-
if perf and not sys.platform.startswith("linux"):
73-
raise RuntimeError("perf profiling is only supported on Linux")
74-
if pystats and not sys.platform.startswith("linux"):
75-
raise RuntimeError("Pystats is only supported on Linux")
76-
56+
def main():
7757
venv = Path("venv")
7858
create_venv(venv)
7959
install_requirements(venv)
8060

8161
# Now that we've installed the full bench_runner library,
8262
# continue on in a new process...
8363

84-
args = ["workflow", fork, ref, machine, benchmarks, flags]
85-
if force:
86-
args.append("--force")
87-
if pgo:
88-
args.append("--pgo")
89-
if perf:
90-
args.append("--perf")
91-
if pystats:
92-
args.append("--pystats")
93-
if force_32bit:
94-
args.append("--32bit")
95-
if run_id:
96-
args.extend(["--run_id", run_id])
97-
98-
run_in_venv(venv, "bench_runner", args)
99-
64+
last_arg = sys.argv.find("workflow_bootstrap.py")
65+
if last_arg == -1:
66+
raise ValueError(
67+
"The script should be run from the command line with the workflow_bootstrap.py argument"
68+
)
10069

101-
def main():
102-
parser = argparse.ArgumentParser(
103-
description="""
104-
Run the full compile/benchmark workflow.
105-
""",
106-
)
107-
parser.add_argument("fork", help="The fork of CPython")
108-
parser.add_argument("ref", help="The git ref in the fork")
109-
parser.add_argument(
110-
"machine",
111-
help="The machine to run the benchmarks on.",
112-
)
113-
parser.add_argument("benchmarks", help="The benchmarks to run")
114-
parser.add_argument("flags", help="Configuration flags")
115-
parser.add_argument("--force", action="store_true", help="Force a re-run")
116-
parser.add_argument(
117-
"--pgo",
118-
action="store_true",
119-
help="Build with profiling guided optimization",
120-
)
121-
parser.add_argument(
122-
"--perf",
123-
action="store_true",
124-
help="Collect Linux perf profiling data (Linux only)",
125-
)
126-
parser.add_argument(
127-
"--pystats",
128-
action="store_true",
129-
help="Enable Pystats (Linux only)",
130-
)
131-
parser.add_argument(
132-
"--32bit",
133-
action="store_true",
134-
dest="force_32bit",
135-
help="Do a 32-bit build (Windows only)",
136-
)
137-
parser.add_argument("--run_id", default=None, type=str, help="The github run id")
138-
args = parser.parse_args()
139-
140-
_main(
141-
args.fork,
142-
args.ref,
143-
args.machine,
144-
args.benchmarks,
145-
args.flags,
146-
args.force,
147-
args.pgo,
148-
args.perf,
149-
args.pystats,
150-
args.force_32bit,
151-
args.run_id,
152-
)
70+
run_in_venv(venv, "bench_runner", ["workflow", *sys.argv[last_arg + 1 :]])
15371

15472

15573
if __name__ == "__main__":

0 commit comments

Comments
 (0)