Skip to content

Commit 47529c8

Browse files
committed
Build jupyterlite in temporary directory, this is needed to prevent side
effects of building it multiple times on the same dir
1 parent 05559a4 commit 47529c8

File tree

2 files changed

+16
-27
lines changed

2 files changed

+16
-27
lines changed

docs/jupyter-lite.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/jupyterlite_sphinx.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import shutil
3+
import tempfile
34

45
from pathlib import Path
56

@@ -155,20 +156,21 @@ def jupyterlite_build(app: Sphinx, error):
155156
if app.builder.format == 'html':
156157
print("[jupyterlite-sphinx] Running JupyterLite build")
157158

158-
subprocess.check_output(
159-
[
160-
"jupyter",
161-
"lite",
162-
"build",
163-
"--debug",
164-
"--contents",
165-
os.path.join(app.srcdir, CONTENT_DIR),
166-
"--output-dir",
167-
os.path.join(app.outdir, JUPYTERLITE_DIR),
168-
]
169-
)
170-
171-
assert os.path.exists(os.path.join(app.outdir, JUPYTERLITE_DIR, 'api', 'contents', 'all.json'))
159+
with tempfile.TemporaryDirectory() as tmp_dir:
160+
subprocess.check_output(
161+
[
162+
"jupyter",
163+
"lite",
164+
"build",
165+
"--debug",
166+
"--lite-dir",
167+
tmp_dir,
168+
"--contents",
169+
os.path.join(app.srcdir, CONTENT_DIR),
170+
"--output-dir",
171+
os.path.join(app.outdir, JUPYTERLITE_DIR),
172+
]
173+
)
172174

173175
print("[jupyterlite-sphinx] JupyterLite build done")
174176

0 commit comments

Comments
 (0)