I'm trying to let people on my project (including myself) migrate to uv
while maintaining compatibility with people who still want to use poetry
(including some of our builds). Now that poetry
2.0 has been released, and the more standard [project]
fields are supported, this should be possible.
It's working well in almost all ways, but the main glitch I'm hitting is the set of dev dependencies. uv
and the standard seem to want them as
[dependency-groups]
dev = [ "bandit ~= 1.8.3", ... ]
while poetry
seems to want them as
[tool.poetry.group.dev.dependencies]
bandit = "^1.8.3"
...
. Without including that section, the dev dependencies get left out of the lockfile when doing poetry lock
.
Anyone have any techniques for getting the two tools to play nicely in this situation?
I'm trying to let people on my project (including myself) migrate to uv
while maintaining compatibility with people who still want to use poetry
(including some of our builds). Now that poetry
2.0 has been released, and the more standard [project]
fields are supported, this should be possible.
It's working well in almost all ways, but the main glitch I'm hitting is the set of dev dependencies. uv
and the standard seem to want them as
[dependency-groups]
dev = [ "bandit ~= 1.8.3", ... ]
while poetry
seems to want them as
[tool.poetry.group.dev.dependencies]
bandit = "^1.8.3"
...
. Without including that section, the dev dependencies get left out of the lockfile when doing poetry lock
.
Anyone have any techniques for getting the two tools to play nicely in this situation?
Share Improve this question asked Mar 20 at 16:40 Ken WilliamsKen Williams 24.1k12 gold badges97 silver badges153 bronze badges 2 |1 Answer
Reset to default 4Until poetry
adds support for PEP-735, you can (ab)use the project.optional-dependencies
to achieve something similar:
[project.optional-dependencies]
dev = ["bandit ~= 1.8.3"]
Since this is a standard table, it can be used by both poetry and uv:
$ poetry sync --extras dev
$ poetry sync --all-extras
$ uv sync --extra dev
$ uv sync --all--extras
The caveat here is that, as the name implies, these optional dependencies are still part of the project metadata and as such they'll be part of the published metadata on PyPI and users will be able to install them with $tool install foobar[dev]
.
uv
orpoetry
- then these two sections might deviate. Maybe one can write a script to take the most updated version? – Gwang-Jin Kim Commented Mar 21 at 11:36[dependency-groups]
as well. – finswimmer Commented Mar 25 at 20:16