feat: Don't bundle api-examples in wheel distribution#2126
Merged
Conversation
Remove api-examples directory from the wheel distribution to reduce package size by ~400KB. The examples are only needed during documentation builds, which always run from the source repository. Changes: - Update MANIFEST.in to prune api-examples directories - Configure setuptools to explicitly exclude api-examples from package data - Add clear error message when docs are built from installed package - Document that api-examples require source repository The documentation build workflow is unchanged and continues to work from the source tree where api-examples are present. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
api-example in wheel distributionapi-examples in wheel distribution
Simplify package-data wildcards from redundant patterns to cleaner syntax: - "www/**/*" → "www/**" - "templates/**/*" → "templates/**" - "api-examples/**/*" → "api-examples/**" The `**` glob pattern already matches all files and subdirectories recursively, making the `/*` suffix redundant. Verified that the wheel still: - Includes 662 www/templates files - Excludes all api-examples files - Maintains same 3.6MB size 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The `[tool.setuptools.package-data]` section specifying `www/**` and `templates/**` was redundant because MANIFEST.in already includes these with `recursive-include` directives. MANIFEST.in directives are respected by both: - Source distribution builds (sdist) - Binary wheel builds (wheel) Only `exclude-package-data` is needed in pyproject.toml to explicitly exclude api-examples, since MANIFEST.in's `prune` directive alone isn't sufficient for wheel builds. Final configuration is now minimal and clean: - MANIFEST.in handles all includes (www, templates) - pyproject.toml handles only the exclude (api-examples) Verified wheel still contains: - 518 www files - 144 template files - 0 api-examples files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
003c97d to
ffafccb
Compare
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Partly addresses #2125
This PR removes the
shiny/api-examples/directory from the distributed package (both wheels and source distributions) to reduce package size and file count. The examples are only needed during documentation builds, which always run from the source repository.Motivation
The
api-examples/directory contains ~310 example files used by the@add_example()decorator to inject code examples into docstrings during documentation generation. These files:SHINY_ADD_EXAMPLES=true(set duringmake docs-quartodoc)Similar to development dependencies, these are build-time artifacts that don't belong in the runtime package.
Changes
1.
MANIFEST.inWhy: Controls what goes into source distributions (
.tar.gz). Theprunedirective explicitly excludes the directories.2.
pyproject.tomlWhy: Controls what goes into binary wheels (
.whl):packages.find: Expanded from inline syntax to dedicated section for better controlexclude-package-data: Explicit blacklist for api-examples as additional safeguardWhy both MANIFEST.in and pyproject.toml?
These control different build artifacts:
.tar.gz) - used by some users, required by PyPI.whl) - used by most users viapip installThe wheel build process doesn't read MANIFEST.in; it uses setuptools configuration from pyproject.toml. We need to exclude api-examples from both to ensure they don't appear in either distribution format.
3.
shiny/_docstring.pyWhy: Provides a clear error message if someone attempts to build docs from an installed package instead of from source.