Skip to content

Commit e997da2

Browse files
committed
feat: add .gitignore and update conf.py for wheel build optimization
1 parent 019aa82 commit e997da2

3 files changed

Lines changed: 88 additions & 7 deletions

File tree

.github/workflows/docs.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ jobs:
5353
- name: Install Playwright browser
5454
run: uv run playwright install chromium --with-deps
5555

56+
# ── Build Pyodide wheel ───────────────────────────────────────────────
57+
# Produces docs/_static/wheels/anyplotlib-0.0.0-py3-none-any.whl so the
58+
# in-browser Pyodide bridge can install the exact source tree that built
59+
# these docs — no PyPI release required.
60+
- name: Build Pyodide wheel
61+
run: |
62+
mkdir -p docs/_static/wheels
63+
uv build --wheel --out-dir docs/_static/wheels/
64+
# Rename to the stable sentinel name micropip expects for URL installs.
65+
cd docs/_static/wheels
66+
for f in anyplotlib-*.whl; do
67+
[ "$f" != "anyplotlib-0.0.0-py3-none-any.whl" ] && mv "$f" anyplotlib-0.0.0-py3-none-any.whl
68+
done
69+
5670
# ── Sphinx build ─────────────────────────────────────────────────────
5771
# -W turns warnings into errors; --keep-going collects all of them.
5872
- name: Build HTML documentation
@@ -110,6 +124,16 @@ jobs:
110124
echo "dest_dir=dev" >> "$GITHUB_OUTPUT"
111125
fi
112126
127+
# ── Build Pyodide wheel ───────────────────────────────────────────────
128+
- name: Build Pyodide wheel
129+
run: |
130+
mkdir -p docs/_static/wheels
131+
uv build --wheel --out-dir docs/_static/wheels/
132+
cd docs/_static/wheels
133+
for f in anyplotlib-*.whl; do
134+
[ "$f" != "anyplotlib-0.0.0-py3-none-any.whl" ] && mv "$f" anyplotlib-0.0.0-py3-none-any.whl
135+
done
136+
113137
# ── Sphinx build ─────────────────────────────────────────────────────
114138
- name: Build HTML documentation
115139
env:

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Python bytecode / caches
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.pyo
6+
7+
# Distribution / packaging
8+
dist/
9+
build/
10+
*.egg-info/
11+
*.egg
12+
.eggs/
13+
14+
# Virtual environments
15+
.venv/
16+
venv/
17+
env/
18+
19+
# Test / coverage artefacts
20+
.pytest_cache/
21+
.coverage
22+
coverage.xml
23+
htmlcov/
24+
25+
# Jupyter notebooks checkpoints
26+
.ipynb_checkpoints/
27+
28+
# Sphinx build output
29+
docs/_build/
30+
build/html/
31+
build/doctrees/
32+
33+
# Generated Pyodide wheel (built by workflow / make html — never commit)
34+
docs/_static/wheels/
35+
36+
# Editor / IDE
37+
.idea/
38+
.vscode/
39+
*.swp
40+
*.swo
41+
42+
# macOS
43+
.DS_Store
44+
45+

docs/conf.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,28 @@
123123
# pyodide_bridge.js derives the wheel URL from its own script src, which
124124
# already carries the version prefix.
125125
def setup(app):
126-
"""Build the anyplotlib wheel for the in-browser Pyodide bridge."""
126+
"""Build the anyplotlib wheel for the in-browser Pyodide bridge.
127+
128+
In CI the workflow pre-builds the wheel before sphinx-build runs, so we
129+
skip the build step if ``anyplotlib-0.0.0-py3-none-any.whl`` is already
130+
present. This avoids a redundant ``pip wheel`` invocation and keeps the
131+
local ``make html`` path working without needing ``uv build``.
132+
"""
127133
import subprocess
128134
import sys
129135
from pathlib import Path
130136

131137
wheels_dir = Path(__file__).parent / "_static" / "wheels"
132138
wheels_dir.mkdir(parents=True, exist_ok=True)
133139

140+
stable = wheels_dir / "anyplotlib-0.0.0-py3-none-any.whl"
141+
142+
# If the wheel was already built by the workflow step (or a previous local
143+
# build), reuse it rather than rebuilding.
144+
if stable.exists():
145+
print(f"[pyodide_bridge] wheel already present → {stable}")
146+
return
147+
134148
# Remove stale wheels from previous builds.
135149
for old in wheels_dir.glob("anyplotlib*.whl"):
136150
old.unlink(missing_ok=True)
@@ -153,13 +167,11 @@ def setup(app):
153167
print(f"\n[pyodide_bridge] WARNING: wheel build failed:\n{result.stderr}")
154168
return
155169

156-
# Rename to a stable, version-agnostic filename so pyodide_bridge.js can
157-
# reference it without knowing the current version string.
158-
# NOTE: "latest" is NOT a valid PEP 440 version; micropip rejects it.
159-
# "0.0.0" is the simplest valid sentinel that micropip accepts when the
160-
# wheel is installed via URL (no PyPI version-check happens for URL installs).
170+
# Rename to the stable sentinel name micropip accepts for URL installs.
171+
# "0.0.0" is a valid PEP 440 version; micropip skips PyPI checks for
172+
# wheels installed by URL so the actual version number doesn't matter.
161173
wheels = sorted(wheels_dir.glob("anyplotlib*.whl"))
162174
if wheels:
163-
stable = wheels_dir / "anyplotlib-0.0.0-py3-none-any.whl"
164175
stable.unlink(missing_ok=True)
165176
wheels[-1].rename(stable)
177+
print(f"[pyodide_bridge] wheel → {stable}")

0 commit comments

Comments
 (0)