@click.command("pack")
@click.option(
"--manifest",
"pyproject_toml_path",
default="pyproject.toml",
type=click.Path(exists=True, dir_okay=False, resolve_path=True),
help="Path to the pyproject.toml manifest file.",
)
@click.option(
"--output",
"output_path",
type=click.Path(dir_okay=False, resolve_path=True),
help="Custom output path for the package (defaults to dist/<name>.psp).",
)
@click.option(
"--launcher-bin",
type=click.Path(exists=True, dir_okay=False, resolve_path=True),
help="Path to launcher binary to embed in the package.",
)
@click.option(
"--builder-bin",
type=click.Path(exists=True, dir_okay=False, resolve_path=True),
help="Path to builder binary (overrides default builder selection).",
)
@click.option(
"--verify/--no-verify",
default=True,
help="Verify the package after building (default: verify).",
)
@click.option(
"--strip",
is_flag=True,
help="Strip debug symbols from launcher binary for size reduction.",
)
@click.option(
"--progress",
is_flag=True,
help="Show progress bars during packaging.",
)
@click.option(
"--quiet",
is_flag=True,
help="Suppress progress output.",
)
@click.option(
"--private-key",
type=click.Path(exists=True, dir_okay=False, resolve_path=True),
help="Path to private key (PEM format) for signing.",
)
@click.option(
"--public-key",
type=click.Path(exists=True, dir_okay=False, resolve_path=True),
help="Path to public key (PEM format, optional if private key provided).",
)
@click.option(
"--key-seed",
type=str,
help="Seed for deterministic key generation.",
)
@click.option(
"--workenv-base",
type=click.Path(exists=True, file_okay=False, resolve_path=True),
help="Base directory for {workenv} resolution (defaults to CWD).",
)
@click.option(
"--output-format",
type=click.Choice(["text", "json"], case_sensitive=False),
help="Output format (or set FLAVOR_OUTPUT_FORMAT env var).",
)
@click.option(
"--output-file",
type=str,
help="Output file path, STDOUT, or STDERR (or set FLAVOR_OUTPUT_FILE env var).",
)
def pack_command(
pyproject_toml_path: str,
output_path: str | None,
launcher_bin: str | None,
builder_bin: str | None,
verify: bool,
strip: bool,
progress: bool,
quiet: bool,
private_key: str | None,
public_key: str | None,
key_seed: str | None,
workenv_base: str | None,
output_format: str | None,
output_file: str | None,
) -> None:
"""Pack the application for one or more target platforms."""
log.debug(
"Starting package command",
manifest=pyproject_toml_path,
output_path=output_path,
quiet=quiet,
)
if not quiet:
pout("🚀 Packaging application...")
_setup_workenv_base(workenv_base)
try:
if not quiet:
pass
built_artifacts = _build_package_artifacts(
pyproject_toml_path,
output_path,
launcher_bin,
builder_bin,
strip,
progress,
quiet,
private_key,
public_key,
key_seed,
)
if not quiet:
pout("🔍 Processing and verifying artifacts...")
_process_built_artifacts(built_artifacts, verify, strip, quiet)
_show_final_results(built_artifacts, quiet)
log.info("Packaging completed successfully", artifact_count=len(built_artifacts))
except (BuildError, PackagingError, click.UsageError) as e:
log.error("Packaging failed", error=str(e), manifest=pyproject_toml_path)
perr(f"❌ Packaging Failed:\n{e}")
raise click.Abort() from e