-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_python.py
More file actions
executable file
Β·58 lines (45 loc) Β· 1.65 KB
/
build_python.py
File metadata and controls
executable file
Β·58 lines (45 loc) Β· 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
"""
Build script for Jupyter Book 2 with Giscus comments
Uses jupyter-book command for building
"""
import os
import subprocess
import sys
def run_command(cmd, description):
"""Run a command and handle errors"""
print(f"π¨ {description}...")
try:
result = subprocess.run(
cmd, shell=True, check=True, capture_output=True, text=True
)
print(f"β
{description} completed successfully")
return True
except subprocess.CalledProcessError as e:
print(f"β {description} failed:")
print(f"Error: {e.stderr}")
return False
def main():
print("π Starting Jupyter Book 2 build process...")
# Install dependencies
if not run_command(
"python3 -m pip install -r requirements.txt", "Installing dependencies"
):
sys.exit(1)
# Ensure jupyter-book is available
print("π§ Ensuring jupyter-book is available...")
run_command("python3 -m pip install --upgrade jupyter-book", "Upgrading jupyter-book")
# Build HTML site with myst
if not run_command("myst build --html", "Building HTML site with myst"):
print("β Build failed")
print("π‘ Make sure jupyter-book is properly installed")
sys.exit(1)
# Inject Vercel Analytics
if not run_command("python3 inject_vercel_analytics.py", "Injecting Vercel Analytics"):
sys.exit(1)
# Inject Giscus comments via post-processing script
if not run_command("python3 inject_giscus.py", "Injecting Giscus comments"):
sys.exit(1)
print("β
Build complete! Static files ready in _build/html/")
if __name__ == "__main__":
main()