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

uv tries to read project.name whenever the project table is present #6760

Closed
edgarrmondragon opened this issue Aug 28, 2024 · 5 comments · Fixed by #6803
Closed

uv tries to read project.name whenever the project table is present #6760

edgarrmondragon opened this issue Aug 28, 2024 · 5 comments · Fixed by #6803
Labels
compatibility Compatibility with a specification or another tool

Comments

@edgarrmondragon
Copy link
Contributor

Here the package metadata may be at fault (quantile-development/dagster-ext#12), but both pypa/build and Poetry are able to build the project without any issues (even if with missing metadata).

@zanieb
Copy link
Member

zanieb commented Aug 28, 2024

Thanks for the report!

Technically, I think it's a violation of the specification to exclude the name field when a [project] table exists.

From the relevant document:

The lack of a [project] table implicitly means the build backend will dynamically provide all keys.

The only keys required to be statically defined are: ... name

I believe the problem is that we see a [project] table so we attempt to extract static metadata from the project without calling into a build backend. I guess the argument here is that [project.urls] doesn't explicitly define a [project] table? That seems weird though.

I see a few options:

  1. We fallback to dynamic metadata retrieval with the build-backend if the static metadata retrieval fails
  2. We special-case implicit [project] table declarations
  3. We continue to be strict here and pursue a clarification in the specification

@zanieb zanieb added the compatibility Compatibility with a specification or another tool label Aug 28, 2024
@zanieb
Copy link
Member

zanieb commented Aug 28, 2024

I'm also reading a bit into the linked issue regarding the implicit table definition — please let me know if you think it's wrong to fail if name is missing even when the project table ([project]) is explicitly defined.

@henryiii
Copy link
Contributor

It's invalid. Tools are supposed to error out. I really dislike that it's required, but not up to me. :) See pypa/cibuildwheel#1064.

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
@FFY00
Copy link

FFY00 commented Sep 5, 2024

I'm also reading a bit into the linked issue regarding the implicit table definition — please let me know if you think it's wrong to fail if name is missing even when the project table ([project]) is explicitly defined.

If there's a project table, the project.name field must be present, but the project table is not required to be present.
If a project table is not present, it means the project is not using PEP 621 metadata, which is perfectly valid.

In this case, it seems the project was mixing the project (PEP 621) and tool.poetry tables when specifying the metadata, which shouldn't really be allowed. I consider this a bug in the build backend.

With this in mind, UV's behavior is correct, however, to achieve better compatibility, I would suggest issuing a warning instead of erroring out in such scenarios.

PS: Feel free to ping me if you have any more issues, or questions, regarding the project metadata, and other issues regarding packaging.

@edgarrmondragon
Copy link
Contributor Author

In this case, it seems the project was mixing the project (PEP 621) and tool.poetry tables when specifying the metadata, which shouldn't really be allowed. I consider this a bug in the build backend.

I agree, though I wonder if it's worth reporting to the Poetry folks, specially since python-poetry/poetry-core#708 is just waiting to be released, and the frontend is WIP (python-poetry/poetry#9135).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Compatibility with a specification or another tool
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants