Skip to content

build: refuse to package without the built frontend - #372

Draft
feanil wants to merge 1 commit into
mainfrom
feanil/require-built-assets
Draft

feanil wants to merge 1 commit into
mainfrom
feanil/require-built-assets

Conversation

@feanil

@feanil feanil commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

The compiled JS and CSS for the discussion, problem and video blocks is webpack output under src/<block>/public/. That folder is gitignored, and setuptools packages whatever is there without complaining, so a package built without running npm ci && npm run build first installs fine but has none of the bundles. Only release.yml runs the npm build today, so a local python -m build or a local semantic-release version produces a broken package. This is how xblocks-contrib 0.16.2 ended up on PyPI without its bundles.

This swaps the build backend for a small in-tree wrapper around setuptools.build_meta that fails the build_sdist and build_wheel hooks when a block with an assets/ folder has no files in its public/ folder. The error names the blocks and says to run the npm build. It doesn't need a setup.py, the wrapper is wired up through backend-path in pyproject.toml.

A few things that stay the same:

  • Editable installs aren't checked, so uv sync and tox still work in a checkout with no bundles. The test jobs in CI never build the frontend and don't need to.
  • The sdist already leaves out assets/ and carries public/, so building a wheel from the sdist, or a pip install of it, doesn't need node.
  • release.yml already runs the npm build before python-semantic-release, so CI releases are unaffected.

Testing

uv build                      # fails, lists src/xblock_{discussion,problem,video}/public
npm ci && npm run build
uv build                      # passes
unzip -Z1 dist/*.whl | grep /public/

The last command should list the 7 bundles. The check itself has unit tests under build_backend/tests, and tox now runs them along with src.

Merge checklist:
Check off if complete or not applicable:

  • Version bumped
  • Changelog record added
  • Documentation updated (not only docstrings)
  • Fixup commits are squashed away
  • Unit tests added/updated
  • Manual testing instructions provided
  • Noted any: Concerns, dependencies, migration issues, deadlines, tickets

Each block's compiled JavaScript and CSS is webpack output under
src/<block>/public/. That folder is gitignored, and setuptools packages
whatever exists without complaint, so a package built without first
running `npm ci && npm run build` installs fine but serves no JS or CSS.
Only release.yml runs the npm build; python-semantic-release's
build_command, `python -m build` and every other local route do not.
xblocks-contrib 0.16.2 shipped to PyPI that way: its wheel is missing all
seven bundles that 0.16.1 has.

Swap the build backend for a thin in-tree wrapper around
setuptools.build_meta that fails build_sdist and build_wheel when a block
with an assets/ folder has an empty or missing public/. The sdist prunes
assets/ and carries public/, so a wheel built from the sdist (and a pip
install of it) needs no node. Editable installs are not checked, so
`uv sync` and tox work in a checkout with no bundles, as CI's test jobs
do.

https://peps.python.org/pep-0517/#in-tree-build-backends

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@feanil
feanil force-pushed the feanil/require-built-assets branch from f894ff6 to 59fc8c7 Compare December 4, 2026 15:41
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.

1 participant