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

Bug: uv publish missing METADATA file #8030

Closed
Tracked by #7839
jamesbraza opened this issue Oct 9, 2024 · 7 comments · Fixed by #8204
Closed
Tracked by #7839

Bug: uv publish missing METADATA file #8030

jamesbraza opened this issue Oct 9, 2024 · 7 comments · Fixed by #8204
Assignees
Labels
bug Something isn't working upstream An upstream dependency is involved

Comments

@jamesbraza
Copy link

I am using uv==0.4.20 and just migrated a publish GitHub Action in a repo using this workspace layout for several packages to uv publish.

    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/setup-uv@v3
        with:
          enable-cache: true
      - run: uv sync
      - name: Build a binary wheel and a source tarball
        run: |
          uv build --sdist --wheel --out-dir dist/ .
          uv build --sdist --wheel --out-dir dist/ packages/bird-feeder
          uv build --sdist --wheel --out-dir dist/ packages/seeds
---      - uses: pypa/gh-action-pypi-publish@release/v1
---        with:
---          password: ${{ secrets.PYPI_API_TOKEN }}
+++      - run: uv publish
+++        env:
+++          UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}

Before, publish worked correctly, but with uv publish I am getting:

warning: `uv publish` is experimental and may change without warning
Publishing 6 files https://upload.pypi.org/legacy/
Uploading seeds-0.7.6-py3-none-any.whl (5.0KiB)
error: Failed to publish `dist/seeds-0.7.6-py3-none-any.whl` to https://upload.pypi.org/legacy/
  Caused by: Upload failed with status code 400 Bad Request. Server says: 400 Wheel 'seeds-0.7.6-py3-none-any.whl' does not contain the required METADATA file: seeds-0.7.6.dist-info/METADATA

Any idea what's going on here? I think this is a uv publish bug given my change was an atomic change, and I was previously using uv build successfully

@konstin
Copy link
Member

konstin commented Oct 9, 2024

What build backend are you using, and could you share more details about your project and your setup? Additionally, seeds-0.7.6-py3-none-any.whl is a zip file, could you look inside and check what seeds-0.7.6.dist-info in there contains?

@konstin konstin added the needs-mre Needs more information for reproduction label Oct 9, 2024
@Avasam
Copy link

Avasam commented Oct 9, 2024

Since I just got the same issue, here's a project: https://github.com/Avasam/typed-D3DShot/tree/24954b8122448926b9afddc1c245796b5e9165a0
And here's the wheel file from uv build: typed_D3DShot-1.0.0-py3-none-any.whl.zip
FWIW, dist-info does contain this metadata file (I added the .txt extention to upload to GitHub:
METADATA

A PyPI issue maybe ? Since I doubt uv publish touches the wheel file's content.

Backend: setuptools
uv version: uv 0.4.20 (0e1b25a 2024-10-08)

@Avasam
Copy link

Avasam commented Oct 9, 2024

Thanks stackoverflow https://stackoverflow.com/a/76757413
It's case sensitive. So uv build issue when naming the folder in the wheel file

I renamed the dist-info folder and it worked. I kept the .whl itself with capital letters.

@jamesbraza
Copy link
Author

I just took a closer look, and in my case it's seemingly a confusion with . vs _ in the package name. In my attempts earlier in this issue to remove my repo's specifics, I also clouded the issue.

The package name is aviary.gsm8k, and in the uv publish logs:

Uploading aviary_gsm8k-0.7.6-py3-none-any.whl (5.0KiB)
error: Failed to publish `dist/aviary.gsm8k-0.7.6-py3-none-any.whl` to https://upload.pypi.org/legacy/
  Caused by: Upload failed with status code 400 Bad Request. Server says: 400 Wheel 'aviary_gsm8k-0.7.6-py3-none-any.whl' does not contain the required METADATA file: aviary_gsm8k-0.7.6.dist-info/METADATA

We see the issue is a mixup with aviary.gsm8k and aviary_gsm8k. Running ls dist:

.gitignore
aviary.gsm8k-0.7.6-py3-none-any.whl
aviary_gsm8k-0.7.6.tar.gz

@konstin konstin removed the needs-mre Needs more information for reproduction label Oct 15, 2024
konstin added a commit that referenced this issue Oct 15, 2024
The spec requires normalizing the name and the version in distribution filenames (https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode). Missing normalization caused #8030, this PR adds a warning for it.
konstin added a commit that referenced this issue Oct 15, 2024
Since setuptools violates the wheel filenames spec (pypa/setuptools#3777), we have to use the raw filename when publishing to get through https://github.com/pypi/warehouse/blob/50a58f3081e693a3772c0283050a275e350004bf/warehouse/forklift/legacy.py#L1133-L1155.

Tested with

```
cargo run publish aviary.gsm8k-0.7.6-py3-none-any.whl --publish-url https://test.pypi.org/legacy/
```

Fixes #8030
@konstin
Copy link
Member

konstin commented Oct 15, 2024

The problem here is that the wheel filename is invalid: All . and - need to replaced with _, so the valid name would be aviary_gsm8k-0.7.6-py3-none-any.whl (https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode). This is a setuptools bug: pypa/setuptools#3777.

We're doing two things about this, one is adding a warning for invalid filenames (#8203), the other is adding a workaround specifically for setuptools (#8204), so this wheel can be uploaded, as it can with twine.

@konstin konstin added bug Something isn't working upstream An upstream dependency is involved labels Oct 15, 2024
konstin added a commit that referenced this issue Oct 15, 2024
The spec requires normalizing the name and the version in distribution filenames (https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode). Missing normalization caused #8030, this PR adds a warning for it.
@jamesbraza
Copy link
Author

Oh thank you @konstin, nice! Just seeking one point of clarification on your above comment, for my understanding:

. and - need to replaced with _, so the valid name would be aviary.gsm8k-0.7.6-py3-none-any.whl

Did you mean to say aviary_gsm8k-0.7.6-py3-none-any.whl?

@konstin
Copy link
Member

konstin commented Oct 15, 2024

yes, sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream An upstream dependency is involved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants