sphinx-pyodide
Sphinx extension to add a pyodide directive for embedding executable Python code blocks in documentation using Pyodide (Python in the browser via WebAssembly).
For full details and examples, refer to the documentation.
How to Use
Install with pip, uv, or similar:
pip install sphinx-pyodide
Enable the extension by including in your Sphinx conf.py:
extensions = ["sphinx_pyodide"]
The output blocks support light and dark mode. For best results, use a Sphinx theme with built-in dark mode support such as Furo or the PyData Sphinx Theme.
Use in documentation files. Build-time output is displayed as static output below each block. Interactive execution requires opt-in — click the Enable Interactive button in the note above the first block to load Pyodide and run blocks live in the browser.
.. pyodide::
print("Hello from Pyodide!")
import numpy as np
print(np.array([1, 2, 3]))
Options
| Option | Type | Description |
|---|---|---|
:packages: |
string | Comma-separated PyPI packages to load (e.g., numpy, pandas). Local .whl files are also supported. |
:editable: |
flag | Allow users to edit the code before running. |
:output: |
string | Static output displayed in the output panel until interactive execution is enabled. |
:show-errors: |
flag | Display runtime errors in the live browser output. |
:setup-code: |
string | Python code to run once before the main block (e.g., imports). |
Development
Setup
Install development dependencies; install pre-commit hooks on first setup.
uv sync --dev
pre-commit install
Testing
Tests use sphinx.testing fixtures via pytest.
pytest tests/
pytest tests/ -k test_name
pytest tests/ --cov=src/sphinx_pyodide
Build Documentation
# One-time build
sphinx-build -b html docs/source docs/build
# Auto-reload with live preview (recommended for development)
sphinx-autobuild docs/source docs/build
Note: Pyodide blocks that install dependencies from local wheels
require an HTTP server (file:// will not work due to CORS).
Options are to build and serve with python -m http.server -d docs/build
or serve with sphinx-autobuild.
Acknowledgments
Substantial portions of this code were developed with assistance from agentic AI coding tools (primarily ClaudeCode & OpenCode and associated models).
License
Apache 2.0
Metadata
Release files for sphinx-pyodide 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sphinx_pyodide-0.1.1.tar.gz | 108.5 kB | Without provenance | Details for sphinx_pyodide-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sphinx_pyodide-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for sphinx_pyodide-0.1.1-py3-none-any.whl |
Total release size: 121.8 kB
Release files / sphinx_pyodide-0.1.1.tar.gz
| Download URL | sphinx_pyodide-0.1.1.tar.gz |
|---|---|
| Size | 108.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a8568e78cda73b4e7469712084f61e39eedf3cd6b210b0fda16319a246156a59
|
|
BLAKE2b-256 checksum How to use checksums |
c6f068a9e03a3c30719f0a725bad9a1b54dfbf2a70b9661111564fc9a5823357
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sphinx_pyodide-0.1.1-py3-none-any.whl
| Download URL | sphinx_pyodide-0.1.1-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f92f52438cc6d600e9a378a3c0e3048a8751b506506a02118d05e203f5b91ebb
|
|
BLAKE2b-256 checksum How to use checksums |
3c466f6d4da49d719b72050b7f600b0403b1f697cf8b3402e6c7da51469ba2f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for sphinx-pyodide 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.