PEP 517 build backend + Sphinx extension that orchestrates Vite via pnpm
Project description
sphinx-vite-builder
PEP 517 build backend and Sphinx extension that transparently orchestrates Vite builds via pnpm for Sphinx-theme packages whose static assets (CSS / JS) are produced by a JavaScript toolchain.
What it solves
A common pattern for modern Sphinx themes is a Python package whose
theme/<name>/static/ directory ships built CSS and JS that were
produced by a JS build tool (Vite, webpack, …). The build artefacts are
gitignored — they're reproducibly built, not source code. But that
creates two friction points:
- Editable installs and source-tree builds crash with confusing
errors when the static dir is empty (e.g. hatchling's
Forced include not found). - CI workflows must duplicate
pnpm install + vite buildsetup steps in every job that touches the package.
sphinx-vite-builder owns the Vite invocation end-to-end — exactly the
way maturin owns Cargo for
Rust+Python packages, or
sphinx-theme-builder
owns webpack for older Sphinx themes.
Two heads, one subprocess core
PEP 517 build backend
Drop-in replacement for hatchling.build. Runs pnpm exec vite build
before delegating wheel/sdist construction to hatchling.
# packages/your-theme/pyproject.toml
[build-system]
requires = ["hatchling>=1.0", "sphinx-vite-builder"]
build-backend = "sphinx_vite_builder.build"
backend-path = ["../sphinx-vite-builder/src"] # for in-tree workspace consumption
The backend short-circuits when web/ (the Vite source tree) is absent
— so pip install <pkg>.tar.gz from an unpacked sdist works without
pnpm or Node, because the sdist already contains pre-baked
static/.
Sphinx extension
Loaded from conf.py. Runs Vite as part of the docs lifecycle:
sphinx-build→pnpm exec vite buildonce before the docs buildsphinx-autobuild→pnpm exec vite build --watchas a child process for the lifetime of the autobuild server, with idempotent re-fire on rebuilds and graceful teardown on signal /atexit
# docs/conf.py
extensions = ["sphinx_vite_builder"]
sphinx_vite_root = "../packages/your-theme/web" # path to vite project
sphinx_vite_mode = "auto" # auto | dev | prod | disabled
Fast-fail diagnostics
When prerequisites are missing the backend / extension raises actionable errors rather than producing broken output:
PnpmMissingError—pnpmnot onPATH; hint includescorepack enableand thepnpm.ioinstall URLNodeModulesInstallError—pnpm installexited non-zero; hint includes the rerun commandViteFailedError—pnpm exec vite buildexited non-zero; hint surfaces the captured stderr
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sphinx_vite_builder-0.0.1a16.dev0.tar.gz.
File metadata
- Download URL: sphinx_vite_builder-0.0.1a16.dev0.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a31717a72b2aa1687323cb1521c6a8268eb85de2fa98213e7d61160b4b96d467
|
|
| MD5 |
0f8767adb9559caf2f63b2b14aa67ba3
|
|
| BLAKE2b-256 |
cabd1a1f96055dda2f6ed6557d9d9f25f571ecb1b82780bd8516afd0343e3f3d
|
Provenance
The following attestation bundles were made for sphinx_vite_builder-0.0.1a16.dev0.tar.gz:
Publisher:
release.yml on git-pull/gp-sphinx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_vite_builder-0.0.1a16.dev0.tar.gz -
Subject digest:
a31717a72b2aa1687323cb1521c6a8268eb85de2fa98213e7d61160b4b96d467 - Sigstore transparency entry: 1434660743
- Sigstore integration time:
-
Permalink:
git-pull/gp-sphinx@3c796e5e35717590d9449314410c78ad9fefefea -
Branch / Tag:
refs/tags/v0.0.1a16.dev0 - Owner: https://github.com/git-pull
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3c796e5e35717590d9449314410c78ad9fefefea -
Trigger Event:
push
-
Statement type:
File details
Details for the file sphinx_vite_builder-0.0.1a16.dev0-py3-none-any.whl.
File metadata
- Download URL: sphinx_vite_builder-0.0.1a16.dev0-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95e8d1b5667fcbddf05835f8ada7a2cee2ac1da3e0359925bc45f159879c2c3c
|
|
| MD5 |
b70c9b39da0fe3c3dd66f619b99bfec8
|
|
| BLAKE2b-256 |
75c1dcea80ded03fafaf530ee1c1f5f6ab07330b8f49dd9b8379bf7c0e80076d
|
Provenance
The following attestation bundles were made for sphinx_vite_builder-0.0.1a16.dev0-py3-none-any.whl:
Publisher:
release.yml on git-pull/gp-sphinx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_vite_builder-0.0.1a16.dev0-py3-none-any.whl -
Subject digest:
95e8d1b5667fcbddf05835f8ada7a2cee2ac1da3e0359925bc45f159879c2c3c - Sigstore transparency entry: 1434661128
- Sigstore integration time:
-
Permalink:
git-pull/gp-sphinx@3c796e5e35717590d9449314410c78ad9fefefea -
Branch / Tag:
refs/tags/v0.0.1a16.dev0 - Owner: https://github.com/git-pull
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3c796e5e35717590d9449314410c78ad9fefefea -
Trigger Event:
push
-
Statement type: