uv icon indicating copy to clipboard operation
uv copied to clipboard

pyproject validation messages are ambiguous

Open lskbr opened this issue 1 year ago • 4 comments

uv --version 0.4.45

also tested with version 0.4.22

OS: Windows 11 - WSL

pyproject.toml:

[project]
name = "x"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
]
 
[project.optional-dependencies]
dev = [
    "rich>=13.9.2",
]

This pyproject.toml was created with uv init. The rich dependency was added with:

uv add rich --optional dev

The problem:

uv pip install --extra dev . -vvvv
    0.002785s DEBUG uv uv 0.4.25
error: Requesting extras requires a `pyproject.toml`, `setup.cfg`, or `setup.py` file.

The message implies that pyproject.toml file does not exist, but it is there.

Installing with

uv pip install .[dev]

works without any problem. Same directory, same venv.

The problem is: if pyptoject.toml exists and is valid, why the error message tells extra requires a pyproject.toml?

This also happens when a [project] section is not present in the pyproject, for example, when it is created with poetry. The error message is the same, even if the pyproject.toml is there and is used by other uv options.

In the first case RUST_TRACE and RUST_LOG do not help, the output is the same. In the second case, missing project header, RUST_TRACE and RUST_LOG can be used to have a hint of the problem.

Can you please have a look if there is an error in uv pip install --help? Can you please consider changing the error message to clearly indicate when a file does not exist and when it exists but is invalid or missing something? Can you please confirm uv should be compatible with the pyproject.toml generated by poetry? (and when poetry is the specified builder).

lskbr avatar Oct 21 '24 12:10 lskbr

I believe uv pip install --extra dev -r pyproject.toml is the expected usage there.

I see how this is confusing though, we can improve this.

zanieb avatar Oct 21 '24 13:10 zanieb

So the -r is missing when I use --extra. By the message I thought it wasn't finding the pyproject file itself. It is also strange that pip install .[dev] works without the -r. So we have two settings: If I use the uv pip install .[dev] notation, I don't have to pass a -r and I should not use --extra. If I use uv pip install -extra dev I have to pass the -r pyproject.toml. Is this correct?

lskbr avatar Oct 21 '24 15:10 lskbr

.[dev] and -r pyproject.toml aren't quite the same. The former installs the project itself; the latter installs the project's requirements.

charliermarsh avatar Oct 21 '24 15:10 charliermarsh

Same problem

  • https://github.com/astral-sh/uv/issues/4762
  • https://github.com/astral-sh/uv/issues/7845

zanieb avatar Oct 21 '24 21:10 zanieb