using optimisation level for interpreter during compilation, fix #3

This commit is contained in:
Florian Förster 2025-04-03 14:13:33 +02:00
parent dccb62fe1b
commit 574596dba7

View File

@ -40,9 +40,16 @@ def compile(
click.echo("Base interpreter path could not be found", err=True)
return
opt_level: str = ""
if optimise == 1:
opt_level = "-O"
elif optimise == 2:
opt_level = "-OO"
exclude_rx: str = "[\\\\|/]+tcl[\\\\|/]+"
cmd = [
run_cmd: list[str] = [
str(pth_intp),
opt_level,
"-m",
"compileall",
"./python/",
@ -52,10 +59,12 @@ def compile(
str(optimise),
]
if force:
cmd.extend(("-f",))
run_cmd.extend(("-f",))
run_cmd = [cmd for cmd in run_cmd if cmd]
try:
subprocess.run(cmd)
subprocess.run(run_cmd)
except Exception as err:
print_error(err)
return