pypa / hatch

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

Support for `uv` workspace #1639

Open JP-Ellis opened 4 months ago

JP-Ellis commented 4 months ago

Summary

Provide compatibility with uv workspaces.

Background

uv has recently added support for workspaces which you can read about here. When configured, all packages within a specific workspace are all automatically installed as editable. Workspaces also provides support for specific overrides, for example, by specifying that a package should be installed from a git+https link, or some absolute path.

In theory, uv automatically discovers the pyproject.toml file and any parent pyproject.toml file. For example, when using uv's own environment, running uv pip install --editable '.[devel]' works seamlessly. Unfortunately, the way Hatch invokes uv pip install somehow interfers with uv's automatic discovery of workspaces.

Workaround

The workaround at the moment is to run uv pip install --editable ... by hand using Hatch's pre-install commands. For example, the following works fine:

[tool.hatch.envs.default]
installer            = "uv"
features             = ["devel"]
pre-install-commands = ["uv pip install '.[devel]'"]  # omitting this results in a failure

It is unclear to me how this is a workaround, as I would have expected Hatch to run the same pre-install command in the background.