uv icon indicating copy to clipboard operation
uv copied to clipboard

Can't compile pyproject.toml to requirements.txt

Open Pixel-Minions opened this issue 6 months ago • 1 comments

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.

image

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"

Pixel-Minions avatar Feb 18 '24 00:02 Pixel-Minions

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.

kpeez avatar Feb 18 '24 00:02 kpeez

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.

Pixel-Minions avatar Feb 18 '24 01:02 Pixel-Minions

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.

charliermarsh avatar Feb 18 '24 02:02 charliermarsh

Also reported in https://github.com/astral-sh/uv/issues/1597

zanieb avatar Feb 18 '24 07:02 zanieb

Closing in favor of https://github.com/astral-sh/uv/issues/1630. Thanks for reporting!

zanieb avatar Feb 18 '24 07:02 zanieb

As of https://github.com/astral-sh/uv/pull/2633 we support reading this directly.

zanieb avatar Mar 25 '24 20:03 zanieb