Skip to content

build(zarr-metadata): give the sdist an explicit include allowlist - #284

Closed
d-v-b wants to merge 1 commit into
mainfrom
claude/zen-elgamal-331b96
Closed

build(zarr-metadata): give the sdist an explicit include allowlist#284
d-v-b wants to merge 1 commit into
mainfrom
claude/zen-elgamal-331b96

Conversation

@d-v-b

@d-v-b d-v-b commented Aug 12, 2026

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

packages/zarr-metadata/pyproject.toml configures the wheel target but not the sdist, so a source distribution carries whatever is sitting in the package directory. Mirrors the fix 8be98fa applied to zarr-indexing in zarr-developers#4222.

Hatchling's default is not "ship everything" — it honors .gitignore. That makes it a denylist, which fails precisely for scratch files whose names nobody anticipated. Building from a dirty tree put .env.local, debug_dump.ipynb, scratch_notes.md and __scratch/dump.json in the tarball, while a .pyc was correctly excluded. A tagged release builds from a fresh CI checkout, so nothing junk has actually shipped — but that was a property of the runner, not of the package.

The list

[tool.hatch.build.targets.sdist]
include = ["/src", "/tests", "/docs", "/mkdocs.yml", "/justfile", "/CHANGELOG.md"]

Derived from this package rather than copied from zarr-indexing, whose list includes /examples and docs/snippets because test_doc_examples.py executes them. Nothing here does: every fixture is a JSON file next to the test module that reads it (Path(__file__).parent / ...), and there is no conftest.py, so /tests is the whole test dependency.

Two judgment calls worth flagging for review:

  • /docs and /mkdocs.yml included despite no test touching them. The site is self-contained — mkdocstrings reads paths: [src], nothing reaches outside the package — so the shipped justfile's docs-check recipe still works from an unpacked sdist. 120K against 768K of tests.
  • changes/ and .readthedocs.yaml excluded. Towncrier fragments are repo bookkeeping, and the RTD config addresses paths from the repo root, where an unpacked sdist is not.

Verification

Dirtied the tree with four scratch files and built both ways:

baseline with allowlist
scratch files in tarball all 4 present none
entries / size 238, 152K

Then unpacked the tarball into /tmp, installed it into a bare venv, and worked from the unpacked directory:

  • pytest595 passed, importing from site-packages rather than the source tree
  • mkdocs build --strict — succeeds
  • hatch-vcs resolved the version from PKG-INFO with no git repo present, so wheel-from-sdist builds fine

No towncrier fragment, matching the zarr-indexing precedent — nothing here is observable to a consumer of the library. Happy to add one if you'd rather it be noted.

…ying around

hatchling had no sdist configuration here either, so a source distribution
carried everything in the package directory. Building from a working tree with
scratch files in it put `.env.local`, a notebook and a `__scratch/` dump in the
tarball. A tagged release builds from a fresh CI checkout and so was never
actually at risk, but nothing made that a property of the package rather than
of the runner.

The list is derived from this package rather than copied from zarr-indexing,
which needed `docs/snippets` and `examples/` because its suite executes them.
Nothing here does: every fixture is a JSON file next to the test module that
reads it, so `/tests` is the whole test dependency. `/docs` and `/mkdocs.yml`
ride along because they are self-contained — mkdocstrings reads `src` and the
config reaches nowhere outside the package — so the sdist documents itself as
well as tests itself. `changes/` and `.readthedocs.yaml` are left out: towncrier
fragments are repo bookkeeping, and the RTD config addresses paths from the
repo root, where an unpacked sdist is not.

Verified by unpacking the built sdist into a bare venv and working from there:
595 tests pass and `mkdocs build --strict` succeeds.

Assisted-by: ClaudeCode:claude-opus-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant