Migrate from pip-install-e + setuptools to a uv workspace with a
committed uv.lock for deterministic deps. Switch both members to
hatchling, and move package sources into nested standard layout
(l4d2host/l4d2host/, l4d2web/l4d2web/) so builds work from a
read-only source tree — setuptools wrote egg-info to source under
the old layout, which broke uv sync on the root-owned /opt/left4me/src.
Local dev install: `pip install -e ./l4d2host -e ./l4d2web` -> `uv sync`.
.envrc switches from `layout python python3.13` to `use uv`. Python
pinned to 3.13 via .python-version.
l4d2web now declares its cross-dep on l4d2host explicitly via
[tool.uv.sources] (workspace = true). l4d2web/alembic.ini and
l4d2web/alembic/ stay at the project root (standard alembic layout).
Test fixes:
- tests/__init__.py added to both test dirs so pytest doesn't shadow
l4d2host as a namespace package via outer-dir walk.
- 3 CWD-relative paths in tests (l4d2web/static/css/{tokens,layout}.css
and js/sse.js) anchored to Path(__file__) so they survive layout
changes.
- Two test_install.py tests now monkeypatch HOME to tmp_path so they
stop silently mutating ~/.steam/sdk32 on every run.
628 tests pass under sandboxed `uv run pytest`.
Per docs/superpowers/plans/2026-05-15-uv-workspace-execution.md;
prereq for the ckn-bw bundle's uv-sync action (queued).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
103 lines
2.9 KiB
Python
103 lines
2.9 KiB
Python
from pathlib import Path
|
|
import json
|
|
import os
|
|
import subprocess
|
|
|
|
import typer
|
|
|
|
from l4d2host.instances import delete_instance, initialize_instance, reset_instance, start_instance, stop_instance
|
|
from l4d2host.logs import stream_instance_logs
|
|
from l4d2host.status import get_instance_status
|
|
from l4d2host.steam_install import SteamInstaller
|
|
|
|
|
|
app = typer.Typer(no_args_is_help=True)
|
|
|
|
|
|
def _exit_from_subprocess_error(exc: subprocess.CalledProcessError) -> None:
|
|
if exc.stderr:
|
|
typer.echo(exc.stderr, err=True)
|
|
raise typer.Exit(code=exc.returncode)
|
|
|
|
|
|
@app.command()
|
|
def install() -> None:
|
|
# LEFT4ME_STEAMCMD lets deployment pin an absolute path (e.g. when the
|
|
# binary lives outside PATH or its steamcmd.sh resolves $0 via dirname,
|
|
# which breaks under PATH-symlink invocation). Default keeps PATH lookup
|
|
# for dev/tests.
|
|
steamcmd = os.environ.get("LEFT4ME_STEAMCMD", "steamcmd")
|
|
try:
|
|
SteamInstaller(steamcmd=steamcmd).install_or_update(passthrough=True)
|
|
except subprocess.CalledProcessError as exc:
|
|
_exit_from_subprocess_error(exc)
|
|
|
|
|
|
@app.command()
|
|
def initialize(name: str, spec: Path = typer.Option(..., "-f")) -> None:
|
|
try:
|
|
initialize_instance(name, spec, passthrough=True)
|
|
except subprocess.CalledProcessError as exc:
|
|
_exit_from_subprocess_error(exc)
|
|
|
|
|
|
@app.command()
|
|
def start(name: str) -> None:
|
|
try:
|
|
start_instance(name, passthrough=True)
|
|
except subprocess.CalledProcessError as exc:
|
|
_exit_from_subprocess_error(exc)
|
|
|
|
|
|
@app.command()
|
|
def stop(name: str) -> None:
|
|
try:
|
|
stop_instance(name, passthrough=True)
|
|
except subprocess.CalledProcessError as exc:
|
|
_exit_from_subprocess_error(exc)
|
|
|
|
|
|
@app.command()
|
|
def delete(name: str) -> None:
|
|
try:
|
|
delete_instance(name, passthrough=True)
|
|
except subprocess.CalledProcessError as exc:
|
|
_exit_from_subprocess_error(exc)
|
|
|
|
|
|
@app.command()
|
|
def reset(name: str) -> None:
|
|
try:
|
|
reset_instance(name, passthrough=True)
|
|
except subprocess.CalledProcessError as exc:
|
|
_exit_from_subprocess_error(exc)
|
|
|
|
|
|
@app.command()
|
|
def status(name: str, json_output: bool = typer.Option(False, "--json")) -> None:
|
|
instance_status = get_instance_status(name)
|
|
if json_output:
|
|
typer.echo(
|
|
json.dumps(
|
|
{
|
|
"state": instance_status.state,
|
|
"raw_active_state": instance_status.raw_active_state,
|
|
"raw_sub_state": instance_status.raw_sub_state,
|
|
}
|
|
)
|
|
)
|
|
return
|
|
typer.echo(instance_status.state)
|
|
|
|
|
|
@app.command()
|
|
def logs(
|
|
name: str,
|
|
lines: int = typer.Option(200, "--lines"),
|
|
follow: bool = typer.Option(True, "--follow/--no-follow"),
|
|
) -> None:
|
|
try:
|
|
for line in stream_instance_logs(name, lines=lines, follow=follow):
|
|
typer.echo(line)
|
|
except subprocess.CalledProcessError as exc:
|
|
_exit_from_subprocess_error(exc)
|