Fix build config to exclude sibling packages from distributions - #6966
Merged
Conversation
Hatchling matches `include` and `artifacts` with gitignore semantics, so an unanchored pattern matches at any depth, and `artifacts` is checked before `include` and bypasses it entirely. Both mattered here. `artifacts = ["*.pyi"]` swept in every generated stub in the workspace -- 163 files under packages/, each already bundled by the package that owns it, plus the 12 pyi_generator golden fixtures under tests/. And `include = ["reflex", ...]` matched the nested packages/reflex-base/src/reflex_base/.templates/web/components/reflex/ directory, dragging a stray .js file along with it. The wheel therefore installed a top-level `packages/` directory next to `reflex/` in site-packages. Anchoring both patterns to the repository root drops the sdist and wheel from 308 files to 132, and the wheel from 770 KB to 280 KB. Add tests that assert both builders select nothing outside reflex/ and the build hook, checked against the config we ship rather than a copy of it.
…acts Two follow-ups in the same vein as anchoring the root patterns. `scripts/hatch_build.py` only needs to reach the sdist, so that a wheel can be built from it. Shipping it in the wheel installed a top-level `scripts` directory into site-packages -- a far more collision-prone name than the `packages` one just removed. Moving it to `targets.sdist.include` leaves the wheel with `reflex/` alone. The 14 packages that generate stubs still declared `artifacts = ["*.pyi"]`. That is harmless today only because each build root is the package's own directory; the pattern is the same footgun that let the root config reach into packages/. Anchor them to `/src/**/*.pyi` and collapse the two identical per-target keys into one. Tests cover both: the walk test now distinguishes the two targets, and every stub-generating package is checked to select its own `src` stubs and nothing beside them. Discovery keys off the `reflex-pyi` build hook so that removing a package's patterns fails its assertions rather than dropping it from the parametrization.
The news fragment was written for a reviewer: it explained hatchling's pattern semantics, counted the files, and narrated the two bugs. All of that is a click away in the PR. Cut it to what a downstream user needs to know. Document that expectation in AGENTS.md so the next fragment starts there, and add the fragment to the submission checklist. The per-package build comment repeated a paragraph of hatchling semantics across 14 files. One line is enough; the reason the two per-target keys collapse into one is that both targets want the same patterns, and a build-level `artifacts` applies to every target.
The brevity rule was easy to read as "never more than two sentences", which would cut the one thing a deprecation entry is most useful for: showing the supported form beside the old one. Say what the rule is actually about, and where the cutoff to docs falls.
Contributor
Greptile SummaryThe PR narrows Hatch build selection so the main and workspace distributions exclude sibling packages and test artifacts.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| pyproject.toml | Anchors the main package build inputs and limits the custom build hook to source distributions. |
| tests/units/test_build_config.py | Adds coverage for root package selection, build-hook inclusion, and workspace-package isolation. |
| packages/reflex-components-core/pyproject.toml | Restricts generated stub artifacts to the package-local source tree. |
| AGENTS.md | Adds changelog-fragment guidance and updates the pre-submission checklist. |
Reviews (3): Last reviewed commit: "Merge branch 'main' into claude/reflex-p..." | Re-trigger Greptile
Merging this PR will not alter performance
Comparing Footnotes
|
tomllib is stdlib only on 3.11+, so collection failed on the 3.10 leg of the matrix. The repo's fallback elsewhere is `import tomli as tomllib`, but there is no second parser to reach for here: the builder already exposes the parsed `[tool.hatch.build]` table, and it is the same parse the assertions run against. Verified on 3.10 and 3.14.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
Description
This PR fixes the Hatch build configuration to prevent sibling workspace packages and test fixtures from being included in published wheels and sdists. The main
reflexpackage was inadvertently shipping files frompackages/subdirectories and test golden files, bloating distributions unnecessarily.Changes:
Root
pyproject.toml: Updated[tool.hatch.build]to use anchored include patterns (/reflex,/scripts/hatch_build.py) that only match at the repo root, preventing nestedpackages/*/src/directories from being included. Moved the build hook totargets.sdist.includeso it's only shipped in sdists (needed to build wheels from sdists), not in wheels themselves.All
packages/*/pyproject.toml: Standardized artifact patterns from*.pyi(which matched anywhere) to/src/**/*.pyi(anchored to each package's root), ensuring each package only ships its own generated stubs.Tests: Added comprehensive test suite (
tests/units/test_build_config.py) that validates:Documentation: Updated
AGENTS.mdwith changelog fragment guidelines and adjusted the pre-submission checklist.Changelog: Added news fragment documenting the size reduction.
Test Plan
Added 114 lines of unit tests covering all build configuration scenarios:
test_build_selects_reflex_files: Verifies core reflex files are includedtest_build_skips_files_outside_reflex: Verifies sibling packages and fixtures are excludedtest_build_walks_only_the_reflex_tree: Validates no unexpected files are includedtest_sdist_ships_the_build_hook/test_wheel_omits_the_build_hook: Ensures correct hook distributiontest_package_ships_only_its_own_stubs: Validates each workspace package's isolationAll tests pass for both
SdistBuilderandWheelBuilder.Checklist
uv run ruff check .anduv run ruff format .cleanuv run pyright reflex testspasseshttps://claude.ai/code/session_014sgS35XWLy5xpVZqgHXupg