Is there a command for uv that exports/extracts just the dependencies declared as dev dependencies from the pyproject.toml
file, for example to pass test dependencies to tox?
uv add Django
uv add pytest --dev
Results in this pyproject.toml
:
[project]
dependencies = [
"django>=4.2.15",
]
[tool.uv]
dev-dependencies = [
"pytest>=8.3.2",
]
How can I generate a file that only contains the dev dependencies, basically a requirements-dev.txt
?
uv pip compile pyproject.toml
does not include the dev deps, only the main deps. And I did not see an argument to make it include it:
Resolved 4 packages in 83ms
# This file was autogenerated by uv via the following command:
# uv pip compile pyproject.toml
asgiref==3.8.1
# via django
django==4.2.15
# via hatch-demo (pyproject.toml)
sqlparse==0.5.1
# via django
typing-extensions==4.12.2
# via asgiref
For comparison, poetry has poetry export --only dev -o requirements-dev.txt
, which will generate something like this:
iniconfig==2.0.0 ; python_version >= "3.12" and python_version < "4.0"
packaging==24.1 ; python_version >= "3.12" and python_version < "4.0"
pluggy==1.5.0 ; python_version >= "3.12" and python_version < "4.0"
pytest==8.3.2 ; python_version >= "3.12" and python_version < "4.0"
Update uv to the version 0.4.11 or greater (uv self update
), and use the following command:
uv export --only-dev --no-hashes | awk '{print $1}' FS=' ;' > requirements-dev.txt