-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Summary
TLDR - Remove remaining Poetry references from CLI commands and add uv tool run as a fallback for running cookiecutter when it's not installed as a Python package. This completes the UV migration for user-facing tooling.
Context
The harp create project command uses cookiecutter to generate new projects. Currently:
- The error message references
poetry install -E dev(line 18 inharp/commandline/create.py) - The docs development command uses
poetry run sphinx-autobuild(line 94 inharp/commandline/utils/manager.py)
The cookiecutter templates themselves have already been migrated to UV (using hatchling, UV-based Makefiles).
Files to modify
harp/commandline/create.py- cookiecutter invocation and error messageharp/commandline/utils/manager.py- docs command
Implementation
Cookiecutter invocation strategy
Use subprocess consistently in both cases for simpler, more predictable behavior:
- Check if
cookiecutteris available as an installed package → run viasubprocess.run(["cookiecutter", ...]) - If not found, check if
uvis available → run viasubprocess.run(["uv", "tool", "run", "cookiecutter", ...]) - If neither is available, show error with UV-based installation instructions
# Pseudocode flow:
if shutil.which("cookiecutter"):
subprocess.run(["cookiecutter", template_path], check=True)
elif shutil.which("uv"):
subprocess.run(["uv", "tool", "run", "cookiecutter", template_path], check=True)
else:
raise UsageError("Install cookiecutter with `uv add harp-proxy --extra dev` or ensure `uv` is available to run it via `uv tool run`.")This approach:
- Removes the need to import cookiecutter as a Python module
- Makes both code paths behave identically (subprocess)
- Simplifies error handling
Error message update
Change error message from:
"You need to install cookiecutter to use this command (or use the
devextra, for example usingpip install harp-proxy[dev]orpoetry install -E dev)."
To:
"Install cookiecutter with
uv add harp-proxy --extra devor ensureuvis available to run it viauv tool run."
Docs command update
Change harp/commandline/utils/manager.py:94 from:
"poetry run sphinx-autobuild . _build/html"To:
"uv run sphinx-autobuild . _build/html"Testing Scenarios
- Happy Path (cookiecutter installed):
cookiecutterbinary available → runs via subprocess - Happy Path (uv fallback):
cookiecutternot found,uvavailable → runsuv tool run cookiecutter - Error Case: Neither
cookiecutternoruvavailable → shows UV-only error message