Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error message for invalid [project] table #6419

Closed
soof-golan opened this issue Aug 22, 2024 · 5 comments · Fixed by #6803
Closed

Better error message for invalid [project] table #6419

soof-golan opened this issue Aug 22, 2024 · 5 comments · Fixed by #6803
Labels
error messages Messaging when something goes wrong upstream An upstream dependency is involved

Comments

@soof-golan
Copy link
Contributor

Hey Astral team!

I found an interesting behavior around installing a git based project that is managed by poetry (as opposed to any other build system).
Since the name of the project is defined under the tool.poetry section uv fails to pick it up when reading the pyproject.toml file.
I'm not sure if this is considered Poetry's fault, but pip definitely succeeds in installing this exact package. I have not checked whether this issue can be also replicated locally with a relative path package.

Many thanks 🙏

What Happens

uv fails to install a (seemingly) valid python dependency. pip successfully installs this project.

Expected Behavior

uv should install the package

Reproduction

cd $(mktemp -d)
uv venv
uv pip install -v git+https://github.com/elevenlabs/elevenlabs-python.git@6db2fdd7458ce5c7f1bbdc2c3936784f995acd44

outputs:

Using Python 3.12.5
Creating virtualenv at: .venv
Activate with: source .venv/bin/activate
DEBUG uv 0.3.1
DEBUG Searching for Python interpreter in system path
DEBUG Found `cpython-3.12.5-macos-aarch64-none` at `/private/var/folders/f0/m68x433x79n628trx7zp0x3h0000gn/T/tmp.BZTiKhI3Af/.venv/bin/python3` (virtual environment)
DEBUG Using Python 3.12.5 environment at .venv/bin/python3
DEBUG Acquired lock for `.venv`
DEBUG At least one requirement is not satisfied: git+https://github.com/elevenlabs/elevenlabs-python.git@6db2fdd7458ce5c7f1bbdc2c3936784f995acd44
DEBUG Using request timeout of 30s
DEBUG Fetching source distribution from Git: https://github.com/elevenlabs/elevenlabs-python.git
DEBUG Acquired lock for `https://github.com/elevenlabs/elevenlabs-python`
DEBUG Using existing git source `Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("github.com")), port: None, path: "/elevenlabs/elevenlabs-python.git", query: None, fragment: None }`
DEBUG Acquired lock for `/Users/soof/Library/Caches/uv/built-wheels-v3/git/8be1b43a58e07c63/6db2fdd7458ce5c7`
DEBUG No static `PKG-INFO` available for: git+https://github.com/elevenlabs/elevenlabs-python.git@6db2fdd7458ce5c7f1bbdc2c3936784f995acd44 (MissingPkgInfo)
error: Failed to extract static metadata from `pyproject.toml`
  Caused by: TOML parse error at line 31, column 2
   |
31 | [project.urls]
   |  ^^^^^^^
missing field `name`
image

uv --version

uv 0.3.1 (be17d132a 2024-08-21)

Platform

macOS Sonoma

@konstin konstin added the bug Something isn't working label Aug 22, 2024
@konstin
Copy link
Member

konstin commented Aug 22, 2024

We should fall back to building instead of trying to the read the metadata here, as we're doing in other cases, this is a bug.

Is there a reason you're using [project.urls] here instead of [tool.poetry.urls]?

@konstin konstin added good first issue Good for newcomers and removed good first issue Good for newcomers labels Aug 22, 2024
@soof-golan
Copy link
Contributor Author

soof-golan commented Aug 22, 2024

@konstin
Thanks for the fast response :)
This is not a project I own / maintain, but an external package that is specified as a git dependency in another project.

(This is why I wrote seemingly valid)

uv fails to install a (seemingly) valid python dependency

@charliermarsh
Copy link
Member

@konstin -- I'm somewhat unsure... It is spec-incompliant. If we accept it here, we risk false negatives for other projects.

@konstin konstin removed the bug Something isn't working label Aug 22, 2024
@konstin
Copy link
Member

konstin commented Aug 22, 2024

Oh right, because it's not dynamic like in the other cases.

We should change the error message with a note about the [project] table spec, maybe linking to https://packaging.python.org/en/latest/guides/writing-pyproject-toml/

@konstin konstin assigned konstin and unassigned konstin Aug 26, 2024
@konstin
Copy link
Member

konstin commented Aug 26, 2024

The toml crate doesn't give us this information unfortunately, so we can add better context to the error message: toml-rs/toml#778

@konstin konstin changed the title uv fails to install git pacakges managed by poetry Better error message for invalid [project] table Aug 26, 2024
@konstin konstin added upstream An upstream dependency is involved error messages Messaging when something goes wrong labels Aug 26, 2024
konstin added a commit that referenced this issue Aug 29, 2024
We got user reports where users were confused about why they can't use `[project.urls]` without other `pyproject.toml`. This PR adds a hint that (according to PEP 621), you need to set `project.name` when using any `project` fields`. (PEP 621 also requires `project.version` xor `dynamic = ["version"]`, but we check that later.)

The intermediate parsing layer to tell apart syntax errors from schema errors doesn't incur a performance penalty according to epage (toml-rs/toml#778 (comment)).

Closes #6419
Closes #6760
konstin added a commit that referenced this issue Aug 29, 2024
We got user reports where users were confused about why they can't use `[project.urls]` without other `pyproject.toml`. This PR adds a hint that (according to PEP 621), you need to set `project.name` when using any `project` fields`. (PEP 621 also requires `project.version` xor `dynamic = ["version"]`, but we check that later.)

The intermediate parsing layer to tell apart syntax errors from schema errors doesn't incur a performance penalty according to epage (toml-rs/toml#778 (comment)).

Closes #6419
Closes #6760
konstin added a commit that referenced this issue Aug 30, 2024
We got user reports where users were confused about why they can't use `[project.urls]` without other `pyproject.toml`. This PR adds a hint that (according to PEP 621), you need to set `project.name` when using any `project` fields`. (PEP 621 also requires `project.version` xor `dynamic = ["version"]`, but we check that later.)

The intermediate parsing layer to tell apart syntax errors from schema errors doesn't incur a performance penalty according to epage (toml-rs/toml#778 (comment)).

Closes #6419
Closes #6760
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error messages Messaging when something goes wrong upstream An upstream dependency is involved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants