-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Summary
When running harp create project from an editable/development install of harp, the generated project should use the same editable install by default. This enables a seamless development workflow where changes to harp are immediately reflected in generated projects.
Context
Current behavior: Generated projects always depend on "harp-proxy" from PyPI.
Desired behavior: Auto-detect if harp is installed as editable and generate appropriate dependency.
Files involved:
harp/commandline/create.py- command implementationharp/commandline/cookiecutters/project/{{cookiecutter.__dir_name}}/pyproject.toml- template
Implementation
Detection Logic
Check if harp is running from a development environment:
from harp import ROOT_DIR
import os
def is_editable_install():
"""Detect if harp is installed as editable (development mode)."""
return os.path.exists(os.path.join(ROOT_DIR, ".git"))CLI Changes
Add --pypi flag to force PyPI version even when editable is detected:
@click.option("--pypi", is_flag=True, help="Force PyPI dependency even if running from editable install")
def create(template, name, no_app, no_config, pypi):Template Changes
Update cookiecutter.json to include new variable:
{
"harp_dependency": "harp-proxy",
...
}Update pyproject.toml template:
dependencies = [
"{{cookiecutter.harp_dependency}}",
]Dependency Generation
from harp import ROOT_DIR
if pypi or not is_editable_install():
harp_dependency = "harp-proxy"
else:
# Editable install: use absolute file:// URL
harp_dependency = f"harp-proxy @ file://{ROOT_DIR}"
extra_context["harp_dependency"] = harp_dependencyBehavior Matrix
| Current Install | --pypi flag |
Result |
|---|---|---|
| PyPI | No | "harp-proxy" |
| PyPI | Yes | "harp-proxy" |
| Editable | No | "harp-proxy @ file:///path/to/harp" |
| Editable | Yes | "harp-proxy" |
Testing Scenarios
- PyPI install: Generated project has
"harp-proxy"dependency - Editable install: Generated project has
"harp-proxy @ file:///path/to/harp"dependency - Editable with --pypi: Generated project has
"harp-proxy"dependency