-
Notifications
You must be signed in to change notification settings - Fork 732
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
regression: uv build silently produces empty wheels with hatchling if .gitignore is missing #8200
Comments
What's confusing here is that in my local dev env, |
No one will believe me, BUT, the presence of a |
No useful verbose logging diff between the failing and working builds: 32d31
< DEBUG Found fresh response for: https://files.pythonhosted.org/packages/88/5f/e351af9a41f866ac3f1fac4ca0613908d9a41741cfcf2228f4ad853b697d/pluggy-1.5.0-py3-none-any.whl.metadata
33a33
> DEBUG Found fresh response for: https://files.pythonhosted.org/packages/88/5f/e351af9a41f866ac3f1fac4ca0613908d9a41741cfcf2228f4ad853b697d/pluggy-1.5.0-py3-none-any.whl.metadata
41c41
< DEBUG Installing in hatchling==1.25.0, packaging==24.1, pathspec==0.12.1, pluggy==1.5.0, trove-classifiers==2024.10.13 in /home/user/.cache/uv/builds-v0/.tmpnuqDDO
---
> DEBUG Installing in hatchling==1.25.0, packaging==24.1, pathspec==0.12.1, pluggy==1.5.0, trove-classifiers==2024.10.13 in /home/user/.cache/uv/builds-v0/.tmpE02Jyf
50c50
< DEBUG Calling `hatchling.build.build_sdist("/vol/home/src/uv-repro.git/dist/.tmpigoeaQ", {})`
---
> DEBUG Calling `hatchling.build.build_sdist("/vol/home/src/uv-repro.git/dist/.tmpmpoSRe", {})`
72,73c72,73
< DEBUG Split specific environment resolution took 0.000s
< DEBUG Installing in hatchling==1.25.0, packaging==24.1, pathspec==0.12.1, pluggy==1.5.0, trove-classifiers==2024.10.13 in /home/user/.cache/uv/builds-v0/.tmpsS489a
---
> DEBUG Split specific environment resolution took 0.001s
> DEBUG Installing in hatchling==1.25.0, packaging==24.1, pathspec==0.12.1, pluggy==1.5.0, trove-classifiers==2024.10.13 in /home/user/.cache/uv/builds-v0/.tmptTLjxm
82c82
< DEBUG Calling `hatchling.build.build_wheel("/vol/home/src/uv-repro.git/dist/.tmpUJojVo", {}, None)`
---
> DEBUG Calling `hatchling.build.build_wheel("/vol/home/src/uv-repro.git/dist/.tmp3We1rG", {}, None)` |
Thanks @jinnatar -- we're taking a look! |
(@konstin has been debugging to try and understand why hatchling is behaving this way.) |
Related pypa/hatch#1273 |
Tried a |
When building a source distribution to a wheels, we perform the build inside a temporary directory inside the output directory. By default, the output directory is `dist/` in the repository root. This temp dir placement allows us to move the final wheel to the output directory instead of copying it (a temp dir might be on another device, which means we need to copy instead of moving). Some build backends such as hatchling traverse upwards from the current directory (the source dist build location) looking for gitignore files to consider. By adding a gitignore in `dist/` with `*`, we caused hatchling to ignore all files in our temporary build directory below it, causing empty wheels. To prevent this, we add a `.git` file as a phony git root. We are already using this trick successfully in the cache. Hatchling sees this `.git` file, considers it a boundary and does not traverse up to `dist/.gitignore`. I'd appreciate an eye on potential side effects of adding a `.git` here that I've missed. Fixes #8200
When building a source distribution to a wheels, we perform the build inside a temporary directory inside the output directory. By default, the output directory is `dist/` in the repository root. This temp dir placement allows us to move the final wheel to the output directory instead of copying it (a temp dir might be on another device, which means we need to copy instead of moving). Some build backends such as hatchling traverse upwards from the current directory (the source dist build location) looking for gitignore files to consider. By adding a gitignore in `dist/` with `*`, we caused hatchling to ignore all files in our temporary build directory below it, causing empty wheels. To prevent this, we add a `.git` file as a phony git root. We are already using this trick successfully in the cache. Hatchling sees this `.git` file, considers it a boundary and does not traverse up to `dist/.gitignore`. I'd appreciate an eye on potential side effects of adding a `.git` here that I've missed. Fixes #8200
When building a source distribution to a wheels, we perform the build inside a temporary directory inside the output directory. By default, the output directory is `dist/` in the repository root. This temp dir placement allows us to move the final wheel to the output directory instead of copying it (a temp dir might be on another device, which means we need to copy instead of moving). Some build backends such as hatchling traverse upwards from the current directory (the source dist build location) looking for gitignore files to consider. By adding a gitignore in `dist/` with `*`, we caused hatchling to ignore all files in our temporary build directory below it, causing empty wheels. To prevent this, we add a `.git` file as a phony git root. We are already using this trick successfully in the cache. Hatchling sees this `.git` file, considers it a boundary and does not traverse up to `dist/.gitignore`. I'd appreciate an eye on potential side effects of adding a `.git` here that I've missed. Fixes #8200
I've added a fix and an explanation in #8220, it's a chain of circumstances adding together. Thanks for the great write-up and reproducer, they were very helpful for debugging. |
When building a source distribution to a wheels, we perform the build inside a temporary directory inside the output directory. By default, the output directory is `dist/` in the repository root. This temp dir placement allows us to move the final wheel to the output directory instead of copying it (a temp dir might be on another device, which means we need to copy instead of moving). Some build backends such as hatchling traverse upwards from the current directory (the source dist build location) looking for gitignore files to consider. By adding a gitignore in `dist/` with `*`, we caused hatchling to ignore all files in our temporary build directory below it, causing empty wheels. To prevent this, we add a `.git` file as a phony git root. We are already using this trick successfully in the cache. Hatchling sees this `.git` file, considers it a boundary and does not traverse up to `dist/.gitignore`. Fixes #8200 --------- Co-authored-by: Charlie Marsh <[email protected]>
Summary:
Newer versions of uv build "empty" wheels under the following conditions with
hatchling.build
when depending on hatch default logic of finding the sources atsrc/$project/__init__.py
.0.4.17
0.4.18
.gitignore
or not, where it being missing triggers this issue!Minimal pyproject.toml:
Source contents is only one file at
src/demo/__init__.py
:Dockerfile for repro:
Expected output:
With newer versions instead we get:
demo
package itself is missing, we only get the dist-info, which while technically a valid wheel, doesn't do anything useful either.The text was updated successfully, but these errors were encountered: