Skip to content

Commit 89e35fe

Browse files
committed
build(zarr-metadata): the sdist ships an allowlist, not whatever is lying 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
1 parent f63e61d commit 89e35fe

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Source distributions now ship an explicit allowlist of files instead of
2+
whatever happened to be sitting in the package directory. `pyproject.toml`
3+
configured the wheel target but not the sdist, so hatchling fell back to
4+
including everything the package's `.gitignore` did not match — a denylist,
5+
which catches anticipated junk like `*.pyc` but not a scratch file nobody
6+
thought to ignore. Published sdists were never affected, because a tagged
7+
release is built from a fresh CI checkout, but that was a property of the
8+
release runner rather than of the package.
9+
10+
The sdist keeps `src` and `tests` — every fixture the suite reads lives beside
11+
the test module that reads it — along with `docs`, `mkdocs.yml`, `justfile`
12+
and `CHANGELOG.md`, so an unpacked sdist can still run its own test suite and
13+
build its own documentation. This matters most to downstream packagers, who
14+
build from the sdist rather than the wheel and run the tests against their own
15+
dependency stack.

‎packages/zarr-metadata/pyproject.toml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,26 @@ raw-options = { root = "../..", git_describe_command = "git describe --dirty --t
7171
[tool.hatch.build.targets.wheel]
7272
packages = ["src/zarr_metadata"]
7373

74+
# An allowlist, so nothing that merely happens to sit in the package directory
75+
# — a scratch script, a stray notebook — can ride along in a release. The list
76+
# keeps an sdist self-testing and self-documenting: every fixture this suite
77+
# reads is a JSON file sitting next to the test module that loads it, so
78+
# `/tests` is the whole test dependency, and `/docs` plus `/mkdocs.yml` are a
79+
# self-contained site (mkdocstrings reads `src`, nothing reaches outside the
80+
# package) so `just docs-check` runs from an unpacked sdist too. `changes/`
81+
# and `.readthedocs.yaml` are deliberately absent: towncrier fragments are
82+
# repo bookkeeping, and the RTD config addresses paths from the repo root.
83+
# `pyproject.toml`, `README.md` and `LICENSE.txt` are added by hatchling itself.
84+
[tool.hatch.build.targets.sdist]
85+
include = [
86+
"/src",
87+
"/tests",
88+
"/docs",
89+
"/mkdocs.yml",
90+
"/justfile",
91+
"/CHANGELOG.md",
92+
]
93+
7494
[tool.ruff]
7595
extend = "../../pyproject.toml"
7696
target-version = "py311"

0 commit comments

Comments
 (0)