hatch icon indicating copy to clipboard operation
hatch copied to clipboard

Question: How to install dependencies as editables?

Open Bobronium opened this issue 2 years ago • 2 comments

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

Bobronium avatar Jan 25 '23 14:01 Bobronium

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

Ka55i0peia avatar Mar 07 '23 10:03 Ka55i0peia

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

sirosc avatar Jul 31 '24 23:07 sirosc