Skip to main content

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:

  1. Editable installs and source-tree builds crash with confusing errors when the static dir is empty (e.g. hatchling's Forced include not found).
  2. CI workflows must duplicate pnpm install + vite build setup 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-buildpnpm exec vite build once before the docs build
  • sphinx-autobuildpnpm exec vite build --watch as 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:

  • PnpmMissingErrorpnpm not on PATH; hint includes corepack enable and the pnpm.io install URL
  • NodeModulesInstallErrorpnpm install exited non-zero; hint includes the rerun command
  • ViteFailedErrorpnpm exec vite build exited non-zero; hint surfaces the captured stderr

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx_vite_builder-0.0.1a16.dev0.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinx_vite_builder-0.0.1a16.dev0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_vite_builder-0.0.1a16.dev0.tar.gz.

File metadata

File hashes

Hashes for sphinx_vite_builder-0.0.1a16.dev0.tar.gz
Algorithm Hash digest
SHA256 a31717a72b2aa1687323cb1521c6a8268eb85de2fa98213e7d61160b4b96d467
MD5 0f8767adb9559caf2f63b2b14aa67ba3
BLAKE2b-256 cabd1a1f96055dda2f6ed6557d9d9f25f571ecb1b82780bd8516afd0343e3f3d

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sphinx_vite_builder-0.0.1a16.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_vite_builder-0.0.1a16.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 95e8d1b5667fcbddf05835f8ada7a2cee2ac1da3e0359925bc45f159879c2c3c
MD5 b70c9b39da0fe3c3dd66f619b99bfec8
BLAKE2b-256 75c1dcea80ded03fafaf530ee1c1f5f6ab07330b8f49dd9b8379bf7c0e80076d

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page