feat: Don't bundle api-examples in wheel distribution
#2126
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.