Skip to content

Different files included in wheels between hatch build and build from other tools #1874

Open
@mkniewallner

Description

@mkniewallner

Using include on build targets, I end up with different files included in the final wheel depending on if the build is made with hatch build or through another tool (e.g. build or uv build).

Minimal reproducing example from the repository above:

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "foo"
version = "0.0.1"
description = ""
authors = []
requires-python = "~=3.10"

[tool.hatch.build.targets.sdist]
include = ["sdist.py", "sdist_wheel.py"]

[tool.hatch.build.targets.wheel]
include = ["sdist_wheel.py", "wheel.py"]
  • Building with hatch:
$ uvx [email protected] build && echo "---sdist---" && tar -tzf dist/foo-0.0.1.tar.gz && echo "---wheel---" && unzip -l dist/foo-0.0.1-py3-none-any.whl
[...]
---sdist---
foo-0.0.1/sdist.py
foo-0.0.1/sdist_wheel.py
foo-0.0.1/pyproject.toml
foo-0.0.1/PKG-INFO
---wheel---
Archive:  dist/foo-0.0.1-py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  02-02-2020 00:00   sdist_wheel.py
        0  02-02-2020 00:00   wheel.py
       71  02-02-2020 00:00   foo-0.0.1.dist-info/METADATA
       87  02-02-2020 00:00   foo-0.0.1.dist-info/WHEEL
      322  02-02-2020 00:00   foo-0.0.1.dist-info/RECORD
---------                     -------
      480                     5 files
  • Building with build (same result for uv build):
$ uvx --from [email protected] python -m build && echo "---sdist---" && tar -tzf dist/foo-0.0.1.tar.gz && echo "---wheel---" && unzip -l dist/foo-0.0.1-py3-none-any.whl
[...]
---sdist---
foo-0.0.1/sdist.py
foo-0.0.1/sdist_wheel.py
foo-0.0.1/pyproject.toml
foo-0.0.1/PKG-INFO
---wheel---
Archive:  dist/foo-0.0.1-py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  02-02-2020 00:00   sdist_wheel.py
       71  02-02-2020 00:00   foo-0.0.1.dist-info/METADATA
       87  02-02-2020 00:00   foo-0.0.1.dist-info/WHEEL
      260  02-02-2020 00:00   foo-0.0.1.dist-info/RECORD
---------                     -------
      418                     4 files

With hatch build, wheel.py is included in the wheel, but when invoking build backend through build (or uv build), it is not.

If I update include in [tool.hatch.build.targets.sdist] to include wheel.py, like so:

[tool.hatch.build.targets.sdist]
include = ["sdist.py", "sdist_wheel.py", "wheel.py"]

then when building with build (or uv build), the wheel will include wheel.py.

So it looks like when using another build backend, files included in the wheel that are not also in the sdist are not included.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions