Fix build config to exclude sibling packages from distributions
Type of change
- Bug fix (non-breaking change which fixes an issue)
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 reflex package was inadvertently shipping files from packages/ 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:- Core reflex files are included
- Sibling package files are excluded
- Test fixtures are excluded
- Build hook is only in sdists, not wheels
- Each workspace package only ships its own stubs
-
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 isolation
All tests pass for both SdistBuilder and WheelBuilder.
Checklist
- Tests pass with adequate coverage
-
uv run ruff check .anduv run ruff format .clean -
uv run pyright reflex testspasses - News fragment added for user-facing changes