add pre-release option to venv-add, closes #6

This commit is contained in:
Florian Förster 2025-04-16 15:05:48 +02:00
parent 8c23374f67
commit 1af23910d7
2 changed files with 16 additions and 2 deletions

View File

@ -1,6 +1,6 @@
[project] [project]
name = "pycage" name = "pycage"
version = "0.2.4dev1" version = "0.2.4"
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.2.4dev1" current_version = "0.2.4"
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*)\\.

View File

@ -63,6 +63,7 @@ def add_pkg(
package: str, package: str,
index: str | None = None, index: str | None = None,
extra_index: str | None = None, extra_index: str | None = None,
include_prerelease: bool = False,
) -> None: ) -> None:
cmd: list[str] = [ cmd: list[str] = [
str(interpreter), str(interpreter),
@ -79,11 +80,22 @@ def add_pkg(
if extra_index is not None: if extra_index is not None:
add_opts = ["--extra-index-url", extra_index] add_opts = ["--extra-index-url", extra_index]
cmd.extend(add_opts) cmd.extend(add_opts)
if include_prerelease:
add_opts = ["--pre"]
cmd.extend(add_opts)
subprocess.run(cmd) subprocess.run(cmd)
@click.command(help="install packages directly into the virtual environment") @click.command(help="install packages directly into the virtual environment")
@click.option(
"-p",
"--pre",
is_flag=True,
default=False,
show_default=True,
help=("install pre-release versions"),
)
@click.option( @click.option(
"-e", "--extra-index", default=None, help="extra index to lookup packages at by pip" "-e", "--extra-index", default=None, help="extra index to lookup packages at by pip"
) )
@ -93,6 +105,7 @@ def add(
package: str, package: str,
index: str | None, index: str | None,
extra_index: str | None, extra_index: str | None,
pre: bool,
) -> None: ) -> None:
try: try:
pth_intp = get_interpreter() pth_intp = get_interpreter()
@ -105,6 +118,7 @@ def add(
package=package, package=package,
index=index, index=index,
extra_index=extra_index, extra_index=extra_index,
include_prerelease=pre,
) )