add delete option for precompilation, closes #4
This commit is contained in:
parent
7c632047e4
commit
e04e42c70a
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "pycage"
|
name = "pycage"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
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"},
|
||||||
@ -78,7 +78,7 @@ directory = "reports/coverage"
|
|||||||
|
|
||||||
|
|
||||||
[tool.bumpversion]
|
[tool.bumpversion]
|
||||||
current_version = "0.1.1"
|
current_version = "0.2.3"
|
||||||
parse = """(?x)
|
parse = """(?x)
|
||||||
(?P<major>0|[1-9]\\d*)\\.
|
(?P<major>0|[1-9]\\d*)\\.
|
||||||
(?P<minor>0|[1-9]\\d*)\\.
|
(?P<minor>0|[1-9]\\d*)\\.
|
||||||
@ -111,7 +111,7 @@ pre_commit_hooks = []
|
|||||||
post_commit_hooks = []
|
post_commit_hooks = []
|
||||||
|
|
||||||
[tool.bumpversion.parts.pre_l]
|
[tool.bumpversion.parts.pre_l]
|
||||||
values = ["dev", "a", "b", "rc", "final"]
|
values = ["dev", "rc", "final"]
|
||||||
optional_value = "final"
|
optional_value = "final"
|
||||||
|
|
||||||
[[tool.bumpversion.files]]
|
[[tool.bumpversion.files]]
|
||||||
|
|||||||
@ -4,10 +4,27 @@ import subprocess
|
|||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
|
from pycage import clean
|
||||||
from pycage.helpers import get_interpreter, print_error
|
from pycage.helpers import get_interpreter, print_error
|
||||||
|
|
||||||
|
|
||||||
@click.command(help="precompile all Python files in the standalone distribution")
|
@click.command(help="precompile all Python files in the standalone distribution")
|
||||||
|
@click.option(
|
||||||
|
"-q",
|
||||||
|
"--quiet",
|
||||||
|
is_flag=True,
|
||||||
|
default=False,
|
||||||
|
show_default=True,
|
||||||
|
help=("do not list compiling files during procedure"),
|
||||||
|
)
|
||||||
|
@click.option(
|
||||||
|
"-d",
|
||||||
|
"--delete-existing",
|
||||||
|
is_flag=True,
|
||||||
|
default=False,
|
||||||
|
show_default=True,
|
||||||
|
help=("delete other pre-compiled files before compilation"),
|
||||||
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
"-f",
|
"-f",
|
||||||
"--force",
|
"--force",
|
||||||
@ -33,6 +50,8 @@ from pycage.helpers import get_interpreter, print_error
|
|||||||
def compile(
|
def compile(
|
||||||
optimise: int,
|
optimise: int,
|
||||||
force: bool,
|
force: bool,
|
||||||
|
delete_existing: bool,
|
||||||
|
quiet: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
try:
|
try:
|
||||||
pth_intp = get_interpreter()
|
pth_intp = get_interpreter()
|
||||||
@ -40,12 +59,23 @@ def compile(
|
|||||||
click.echo("Base interpreter path could not be found", err=True)
|
click.echo("Base interpreter path could not be found", err=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if delete_existing:
|
||||||
|
try:
|
||||||
|
clean.delete_files(r"**/*.pyc")
|
||||||
|
except Exception as err:
|
||||||
|
print_error(err)
|
||||||
|
return
|
||||||
|
|
||||||
opt_level: str = ""
|
opt_level: str = ""
|
||||||
if optimise == 1:
|
if optimise == 1:
|
||||||
opt_level = "-O"
|
opt_level = "-O"
|
||||||
elif optimise == 2:
|
elif optimise == 2:
|
||||||
opt_level = "-OO"
|
opt_level = "-OO"
|
||||||
|
|
||||||
|
quiet_opt: str = ""
|
||||||
|
if quiet:
|
||||||
|
quiet_opt = "-q"
|
||||||
|
|
||||||
exclude_rx: str = "[\\\\|/]+tcl[\\\\|/]+"
|
exclude_rx: str = "[\\\\|/]+tcl[\\\\|/]+"
|
||||||
run_cmd: list[str] = [
|
run_cmd: list[str] = [
|
||||||
str(pth_intp),
|
str(pth_intp),
|
||||||
@ -57,6 +87,7 @@ def compile(
|
|||||||
exclude_rx,
|
exclude_rx,
|
||||||
"-o",
|
"-o",
|
||||||
str(optimise),
|
str(optimise),
|
||||||
|
quiet_opt,
|
||||||
]
|
]
|
||||||
if force:
|
if force:
|
||||||
run_cmd.extend(("-f",))
|
run_cmd.extend(("-f",))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user