Skip to content

fix(packaging): keep results/ and data/ out of the sdist - #114

Merged
afterimaginary merged 2 commits into
mainfrom
issue-113
Nov 27, 2026
Merged

afterimaginary merged 2 commits into
mainfrom
issue-113

Conversation

@afterimaginary

Copy link
Copy Markdown
Owner

Closes #113

Summary

The hatchling sdist had no include list, so uv build bundled results/ and data/ and came out at 33 MB. It now holds only the tool's source (src/backread), the tests, and the files a source build needs: pyproject.toml, README.md, LICENSE, plus NOTICE and LICENSES/ once #112 adds them. It's about 160 KB.

Changes

  • only-include for the sdist target, so nothing new at the repo root leaks in by default. Hatchling still adds pyproject.toml, the readme, the licence files and .gitignore itself.
  • src/backread_exp stays out, like it does from the wheel: the experiment runs from a checkout. That means most of the bundled tests import modules the sdist doesn't ship, so they only run from a checkout too.
  • tests/test_packaging.py builds the sdist in-process with hatchling's SdistBuilder (now a dev dependency, so the test runs offline), then checks it's under 1 MB, holds nothing outside the allowed files and directories, and includes every .py file in src/backread.

Verification

  • make ready passes (680 tests).
  • With only-include removed, the new test fails: assert 33060442 < 1000000.
  • uv build builds the sdist and then a wheel from it. With a stand-in NOTICE and LICENSES/Apache-2.0.txt, both end up in the sdist, and NOTICE ends up in the wheel's licenses/.

Observations

  • The wheel picks up LICENSE and NOTICE through hatchling's default licence-file patterns, but not LICENSES/Apache-2.0.txt. If chore: pre-publication check #112 wants that file in the wheel, [project] license-files needs to list it.

The sdist had no include list, so `uv build` bundled results/ and data/
(33 MB). It now holds the tool's source, the tests, the readme and the
licence files, about 160 KB, and a test builds it and checks its files
and size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@afterimaginary

Copy link
Copy Markdown
Owner Author

Review

Verdict: Correct. No P0–P2 defects, one P3 spec note, one P3 defect and one refinement.
Intent: issue #113.

Checked

  • The new sdist is 156,623 bytes. Outside tests/ and src/backread/ it holds only .gitignore, LICENSE, README.md, pyproject.toml and PKG-INFO. The sdist built from origin/main is 33,037,912 bytes.
  • The wheel's file list is the same as main's.
  • The new test runs offline in about 0.08 s as part of make ready. It fails on both the size check and the unexpected-files check if only-include is removed.
  • uv.lock adds only hatchling and its new dependencies (pathspec, tomlkit, trove-classifiers).

Spec

  • [Misread, P3] The sdist ships tests that can't run from it (pyproject.toml:36). 27 of the 38 test modules import backread_exp, and others read PLAN.md, scripts/ or plugin/, none of which are in the sdist. So pytest fails at collection in an unpacked sdist. The literal requirement is met. The options are to accept this and say so, or to narrow the include list to the tool's tests, which would be a list someone has to keep up to date.

Defects

[P3] The test builds with the locked hatchling, but uv build uses the newest one (tests/test_packaging.py:82, tests). Low confidence. [build-system] requires = ["hatchling"] is unpinned, so if a future hatchling changes the files it adds by default, uv build output changes before the locked test sees it. Fix: probably none. Calling uv build from the test would need the network.

Refinements

The comment and the include list disagree about NOTICE (pyproject.toml:34-36, maintain). Hatchling already adds NOTICE through its default licence-file patterns, but LICENSES/ only appears if it's listed. Drop NOTICE from the list, or reword the comment.

Not reviewed: how this combines with #112's real NOTICE and LICENSES/. It was checked with stand-in files only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@afterimaginary

Copy link
Copy Markdown
Owner Author

Review follow-up

Fixed

  • The NOTICE comment. NOTICE is out of only-include, and the comment now says hatchling adds pyproject.toml, the readme and LICENSE/NOTICE itself, while LICENSES/ only comes in when it's listed. I rebuilt with stand-in files and both NOTICE and LICENSES/ are still in the sdist.

Declined

  • Narrowing the tests in the sdist. The issue asks for tests, and a hand-kept list of the tool's own tests would drift. The PR description already says most of them run only from a checkout, just as backread_exp is left out of the wheel.
  • The unpinned hatchling in build-system. Checking the isolated uv build from a test would need the network, and make ready must stay offline. A lower bound wouldn't stop a newer release changing its defaults. If that ever happens, the test catches it the next time the lock is updated.

@afterimaginary
afterimaginary merged commit 0a9088b into main Nov 27, 2026
1 check passed
@afterimaginary
afterimaginary deleted the issue-113 branch November 27, 2026 09:02
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.

Keep results/ and data/ out of the source distribution

1 participant