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]
|
[project]
|
||||||
name = "pycage"
|
name = "pycage"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
description = "tool to handle standalone Python installations from the CLI"
|
description = "tool to handle standalone Python installations from the CLI"
|
||||||
authors = [
|
authors = [
|
||||||
{name = "Florian Förster", email = "f.foerster@d-opt.com"},
|
{name = "Florian Förster", email = "f.foerster@d-opt.com"},
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import compileall
|
import subprocess
|
||||||
import re
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
@ -20,16 +19,6 @@ from pycage.helpers import get_interpreter, print_error
|
|||||||
"timestamps suggest that they did not change"
|
"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(
|
@click.option(
|
||||||
"-o",
|
"-o",
|
||||||
"--optimise",
|
"--optimise",
|
||||||
@ -43,32 +32,32 @@ from pycage.helpers import get_interpreter, print_error
|
|||||||
)
|
)
|
||||||
def compile(
|
def compile(
|
||||||
optimise: int,
|
optimise: int,
|
||||||
workers: int,
|
|
||||||
force: bool,
|
force: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
exclude = re.compile(r"[\\|/]+tcl[\\|/]+")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pth_intp = get_interpreter()
|
pth_intp = get_interpreter()
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
click.echo("Base interpreter path could not be found", err=True)
|
click.echo("Base interpreter path could not be found", err=True)
|
||||||
return
|
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:
|
try:
|
||||||
success = compileall.compile_dir(
|
subprocess.run(cmd)
|
||||||
base_dir,
|
|
||||||
force=force,
|
|
||||||
optimize=optimise,
|
|
||||||
workers=workers,
|
|
||||||
rx=exclude,
|
|
||||||
)
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print_error(err)
|
print_error(err)
|
||||||
|
return
|
||||||
|
|
||||||
if not success:
|
click.echo("The compilation process was successful.")
|
||||||
err = RuntimeError("The compilation process was not successful.")
|
|
||||||
print_error(err)
|
|
||||||
else:
|
|
||||||
click.echo("The compilation process was successful.")
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user