pypa / hatch

Modern, extensible Python project management
https://hatch.pypa.io/latest/
MIT License
6.08k stars 307 forks source link

Question: How to install dependencies as editables? #732

Open Bobronium opened 1 year ago

Bobronium commented 1 year ago

Consider following configuration:

[project.optional-dependencies]
sub_requirement = ["sub_requirement @ {root:uri}/sub_requirement"]

How to tell hatch to install sub_requirement in editable mode? Inserting -e in any place in requirement string gives similar value errors:

      ValueError: Dependency #1 of option `sub_requirement` of field `project.optional-dependencies` is invalid: Expected end or semicolon (after URL and whitespace)
          sub_requirement @ -e file:///Users/bobronium/.../sub_requirement
Ka55i0peia commented 1 year ago

The feature @Bobronium you've mentioned is described here. I was struggling with the same. With this technique you can install from source (also defining a specific git reference like a branch). But it is not installing the dependencies in editable mode (referencing a git clone into src folder of the virtual env, like pip install -e does). 👉 Discussion on that is here #588

sirosc commented 3 months ago

I ended up setting skip-install = true and creating a workaround using requirements.txt files and uv. However, with the latest version of uv you can do this, which seems to work:

[project]
...
dependencies = [
...
"local_dep"
...
]

[tool.uv.sources]
local_dep = { path = "path/to/directory", editable = "true" }

or more simply, add it through the cli: uv add --editable path/to/package/directory