fix usage of wrong interpreter in environment for compilation, closes #2
This commit is contained in:
parent
e293061cf8
commit
45a238c8f9
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "pycage"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
description = "tool to handle standalone Python installations from the CLI"
|
||||
authors = [
|
||||
{name = "Florian Förster", email = "f.foerster@d-opt.com"},
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import compileall
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
import click
|
||||
|
||||
@ -20,16 +19,6 @@ from pycage.helpers import get_interpreter, print_error
|
||||
"timestamps suggest that they did not change"
|
||||
),
|
||||
)
|
||||
@click.option(
|
||||
"-w",
|
||||
"--workers",
|
||||
type=click.INT,
|
||||
default=1,
|
||||
show_default=True,
|
||||
help=(
|
||||
"decide how many workers should be used, if 0: all cores of the machine will be used"
|
||||
),
|
||||
)
|
||||
@click.option(
|
||||
"-o",
|
||||
"--optimise",
|
||||
@ -43,32 +32,32 @@ from pycage.helpers import get_interpreter, print_error
|
||||
)
|
||||
def compile(
|
||||
optimise: int,
|
||||
workers: int,
|
||||
force: bool,
|
||||
) -> None:
|
||||
exclude = re.compile(r"[\\|/]+tcl[\\|/]+")
|
||||
|
||||
try:
|
||||
pth_intp = get_interpreter()
|
||||
except RuntimeError:
|
||||
click.echo("Base interpreter path could not be found", err=True)
|
||||
return
|
||||
|
||||
base_dir = pth_intp.parent
|
||||
exclude_rx: str = "[\\\\|/]+tcl[\\\\|/]+"
|
||||
cmd = [
|
||||
str(pth_intp),
|
||||
"-m",
|
||||
"compileall",
|
||||
".",
|
||||
"-x",
|
||||
exclude_rx,
|
||||
"-o",
|
||||
str(optimise),
|
||||
]
|
||||
if force:
|
||||
cmd.extend(("-f",))
|
||||
|
||||
try:
|
||||
success = compileall.compile_dir(
|
||||
base_dir,
|
||||
force=force,
|
||||
optimize=optimise,
|
||||
workers=workers,
|
||||
rx=exclude,
|
||||
)
|
||||
subprocess.run(cmd)
|
||||
except Exception as err:
|
||||
print_error(err)
|
||||
return
|
||||
|
||||
if not success:
|
||||
err = RuntimeError("The compilation process was not successful.")
|
||||
print_error(err)
|
||||
else:
|
||||
click.echo("The compilation process was successful.")
|
||||
click.echo("The compilation process was successful.")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user