uv
uv copied to clipboard
Can't compile pyproject.toml to requirements.txt
Hi,
I am running issues with the compilation of pyproject.toml to requirements.txt, I am using: `uv pip compile pyproject.toml -o requirements.txt.
This is the content of the toml:
[tool.poetry]
name = "test package"
version = "1.0.0"
description = "test team"
authors = ["test <[email protected]>"]
[tool.poetry.dependencies]
python = "^3.7"
boto3 = "^1.29"
QtPy = "^2.4"
Fileseq = "^1.15"
sentry-sdk = "^1.35"
qtmodern = "^0.2"
pystray = "^0.19"
rpyc = "^5.3"
Your pyproject.toml is set up for poetry. You need to modify it to something like the following:
[project]
name = "test package"
version = "1.0.0"
description = "test team"
authors = [{name = "test", email="[email protected]"}]
dependencies = [
"boto3",
"QtPy",
"Fileseq",
"sentry-sdk",
"qtmodern",
"pystray",
"rpyc",
]
then running uv pip compile -o requirements.txt pyproject.toml
should work as expected.
If you have additional optional dependencies those are specified in a different section:
[project.optional-dependencies]
dev = [
"ruff",
"mypy",
"pytest",
]
and can be generated by running uv pip compile -o requirements-dev.txt --extra=dev pyproject.toml
If you want to specify specific package versions you can see here for more info.
Amazing @AlexWaygood , it works! Thank you. I would have loved to have the conversion from poetry to standard pyproject just because I have some many more. Can I briefly ask @AlexWaygood if does it support virtual environments from embedded versions of python? I tried a moment ago but it seems it doesn't. I can create an issue about it.
Ah yeah, unfortunately we don't support Poetry's metadata format, which is custom to Poetry. Perhaps we should add a custom error message here.
Also reported in https://github.com/astral-sh/uv/issues/1597
Closing in favor of https://github.com/astral-sh/uv/issues/1630. Thanks for reporting!
As of https://github.com/astral-sh/uv/pull/2633 we support reading this directly.