-
I know that there's no supported solution for lock files. But there are external tools for that -- I really like https://github.com/jazzband/pip-tools#requirements-from-pyprojecttoml already mentions Hatch But my case isn't for the project itself, it's for one of the environments. [tool.hatch.envs.docs]
detached = true
dependencies = [
"mkdocs >=1.1.2",
# ...
] But what I still can at least do is ask Hatch for the requirements that it wants for that environment: hatch env show docs Then I just need to pass that to hatch env show --json | jq -r '.docs.dependencies | .[]' | pip-compile -U - -o docs/requirements.txt And it gives us a pinned requirements file! And we can just install it with For people passing by: maybe you'll find these snippets useful. For developers of Hatch: could something be done to make this integration more straightforward? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
Very interesting, I would be interested in something like this as well. I know it's a big deal and we should get the locking mechanism right instead of just rushing into it. But if this is simple enough, we can always deprecate this when we do find a better solution long term for dependency pinning |
Beta Was this translation helpful? Give feedback.
-
As an alternative to [build-system]
requires = ["hatchling", "hatch-requirements-txt"]
[project]
dynamic = ["optional-dependencies"]
[tool.hatch.metadata.hooks.requirements_txt.optional-dependencies]
docs = ["docs/requirements.in"] |
Beta Was this translation helpful? Give feedback.
-
Not sure if I am missing something, but you can do |
Beta Was this translation helpful? Give feedback.
-
I'm also interested in this. Do you think there's scope for a plugin |
Beta Was this translation helpful? Give feedback.
-
I've got a working hatch plugin with It's still early days so I'm very open to suggestions if anyone has any workflow recommendations. Hopefully it's helpful! pip install hatch-pip-compile [tool.hatch.envs.default]
type = "pip-compile" |
Beta Was this translation helpful? Give feedback.
I've got a working hatch plugin with
pip-compile
going over at https://github.com/juftin/hatch-pip-compile.It's still early days so I'm very open to suggestions if anyone has any workflow recommendations. Hopefully it's helpful!