afterpython 0.3.10__py3-none-any.whl → 0.3.11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,15 +41,33 @@ def is_marimo_notebook(path: Path) -> bool:
41
41
  return "__generated_with" in head and "marimo.App(" in head
42
42
 
43
43
 
44
- def _export_marimo(source: Path, output_html: Path, mode: MarimoExportMode):
44
+ def _export_marimo(
45
+ source: Path,
46
+ output_html: Path,
47
+ mode: MarimoExportMode,
48
+ execute: bool = False,
49
+ ):
45
50
  """Run `marimo export` to produce HTML at `output_html`."""
46
51
  output_html.parent.mkdir(parents=True, exist_ok=True)
47
52
  subcommand = "html-wasm" if mode == "wasm" else "html"
48
- cmd = ["marimo", "export", subcommand, str(source), "-o", str(output_html)]
53
+ cmd = [
54
+ "marimo",
55
+ "export",
56
+ subcommand,
57
+ str(source),
58
+ "-o",
59
+ str(output_html),
60
+ "--sandbox",
61
+ "--force",
62
+ ]
49
63
  # WASM-only flag: --mode edit shows code cells (interactive). Without it,
50
64
  # marimo's html-wasm subcommand defaults to "run" which hides them.
65
+ # --sandbox auto-answers marimo's interactive "Run in a sandboxed venv?"
66
+ # prompt; non-interactive builds (CI, `ap build`) would otherwise hang.
51
67
  if mode == "wasm":
52
68
  cmd += ["--mode", "edit"]
69
+ if execute:
70
+ cmd += ["--execute"]
53
71
  result = subprocess.run(cmd, check=False)
54
72
  if result.returncode != 0:
55
73
  raise click.ClickException(f"marimo export failed for {source}")
@@ -85,6 +103,7 @@ def build_marimo_notebook(
85
103
  output_html: Path,
86
104
  content_path: Path,
87
105
  mode: MarimoExportMode = "wasm",
106
+ execute: bool = False,
88
107
  ):
89
108
  """Build a single marimo notebook to HTML and inject the molab badge.
90
109
 
@@ -104,7 +123,7 @@ def build_marimo_notebook(
104
123
  return
105
124
 
106
125
  click.echo(f"Building marimo notebook {source.name} (mode={mode})...")
107
- _export_marimo(source, output_html, mode)
126
+ _export_marimo(source, output_html, mode, execute=execute)
108
127
 
109
128
  # WASM mode runs the notebook in-browser via Pyodide, so molab (a remote
110
129
  # runtime) is redundant. Skip the badge.
@@ -136,9 +155,14 @@ def build_marimo_readme(mode: MarimoExportMode = "wasm"):
136
155
  Skips silently if README.py is absent or isn't a marimo notebook so users
137
156
  who keep only README.md aren't penalized.
138
157
  """
158
+ from afterpython._io.toml import _from_tomlkit
159
+ from afterpython.tools._afterpython import read_afterpython
160
+
139
161
  readme_path = ap.paths.afterpython_path / "README.py"
140
162
  if not readme_path.exists():
141
163
  return
142
164
  output_html = ap.paths.build_path / "readme_py" / "readme_py.html"
143
165
  content_path = Path("README.py")
144
- build_marimo_notebook(readme_path, output_html, content_path, mode)
166
+ website = _from_tomlkit(read_afterpython().get("website", {}))
167
+ execute = bool(website.get("execute_readme_py", False))
168
+ build_marimo_notebook(readme_path, output_html, content_path, mode, execute=execute)
@@ -125,6 +125,7 @@ def init_afterpython():
125
125
  "thumbnail": "thumbnail.png",
126
126
  "announcement": "",
127
127
  "readme_py": "wasm",
128
+ "execute_readme_py": False,
128
129
  "api_reference": False,
129
130
  },
130
131
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: afterpython
3
- Version: 0.3.10
3
+ Version: 0.3.11
4
4
  Summary: CLI tool to streamline Python package maintenance and generate a dedicated project website
5
5
  Keywords: package-maintenance,project-website,static-site-generator,developer-tools,documentation,cli-tool,ci/cd,mystmd,semantic-release,python-packaging
6
6
  Author: Stephen Yau
@@ -23,7 +23,7 @@ Requires-Dist: gitpython>=3.1.50
23
23
  Requires-Dist: python-dotenv>=1.2.2
24
24
  Requires-Dist: pyproject-metadata>=0.11.0
25
25
  Requires-Dist: jupytext>=1.19.2
26
- Requires-Dist: mystmd>=1.9.0
26
+ Requires-Dist: mystmd>=1.9.1
27
27
  Requires-Dist: pdoc>=16.0.0
28
28
  Requires-Dist: ruff>=0.15.12
29
29
  Requires-Dist: pre-commit>=4.6.0
@@ -10,7 +10,7 @@ afterpython/builders/faq_json.py,sha256=mMfFepRBL_1QYO0tQ6orf5ESo2LVntk55nfFzenc
10
10
  afterpython/builders/index_md.py,sha256=ZpBA1FIHgw9MXD8kRaq2OBaEAKnf94_sJmB2cG68iag,6021
11
11
  afterpython/builders/jupyter_notebook.py,sha256=8yjgwWBaHfEzvN90j4biR6-RaTUHeIQ59h4NKethHOk,9693
12
12
  afterpython/builders/llms_txt.py,sha256=9x-B1i1buTDJt4zGs8nugyto_pI5QIp7WUBcv-zpcso,9226
13
- afterpython/builders/marimo_notebook.py,sha256=cIah_ly67tTj4j1y7yL19MRQ9NN6vESmS2JKMsEuaA0,5386
13
+ afterpython/builders/marimo_notebook.py,sha256=dwSQl9sVMUKC1zPwBtGo-K8fKCU7g7qz9qM62jzbu3U,6033
14
14
  afterpython/builders/markdown.py,sha256=0ExfRqvOTWsgUkAVaGGNkiNDtNedRr7JR1yTGxpbsmA,8736
15
15
  afterpython/builders/metadata.py,sha256=EueKoYWM__Hb9MwX0KYejxJvouoaAxD1oz9AP-Na-ZI,3830
16
16
  afterpython/builders/url_md.py,sha256=uuW3YCyphd-Qvl9Yopv48utu6y1tyfJHNc25sS-O6Yw,3526
@@ -49,7 +49,7 @@ afterpython/templates/pdoc/frame.html.jinja2,sha256=GX4pNSuYC4Fq9hvZ01WyaBQes4Fy
49
49
  afterpython/templates/pre-commit-config-template.yaml,sha256=3QkZekg2kK04-Dp8nGc9AsqEdpnh10EcdD6pBhyKpRQ,988
50
50
  afterpython/templates/release-workflow-template.yml,sha256=-vJJlbsroq1BGh0vN1tqJzh8uncn7_73OYn_GTVswCY,1606
51
51
  afterpython/templates/ruff-template.toml,sha256=lNCd4EthoLScr4cyVEgGUH4xK5CfIX3f9I3zkJHAYgg,1008
52
- afterpython/tools/_afterpython.py,sha256=a82taUWoY8yXmzE1m25zV0-vwmyglp5X7G2Erjz3oLw,4345
52
+ afterpython/tools/_afterpython.py,sha256=PYhpFQ27-AMUBnk-fvLnXunTPl0e6QqVwLg-Vd4VRoU,4385
53
53
  afterpython/tools/_git.py,sha256=aO-qDEQ4OevD_B74DYKK4nQKYeiaS1BXmYc8paJRfbQ,3772
54
54
  afterpython/tools/branch_rules.py,sha256=ciQ2H2YBnoCZu_plyVeIHzf2FcAILRFhpjzOR2_IfJg,3159
55
55
  afterpython/tools/commitizen.py,sha256=ZO1qHmzUU0myd85tncv76WtIR7DB_AoQGSUvaf78Ohg,438
@@ -59,7 +59,7 @@ afterpython/tools/pre_commit.py,sha256=oNsrUkPI13rSSBSyhyTTKPnQGhDxLIPYhxu6kL0fD
59
59
  afterpython/tools/pyproject.py,sha256=hz-DOf-pkGBF2m_RqEZipAaO-NDbsLxrrc65LWAIwLA,3698
60
60
  afterpython/utils.py,sha256=fVa3jIzCvhn7QA7N0M6d_pvojpPFrN-hae8trUYhPKU,11701
61
61
  afterpython/version.py,sha256=hihRV1S-gc1m46OaXD32ikkEkqzs-Gtq7AcAqOQV-wY,1603
62
- afterpython-0.3.10.dist-info/WHEEL,sha256=f5fWSvWsg5Knq5GWa6t1nJIug0Tqo69GqAWD_9LbBKw,81
63
- afterpython-0.3.10.dist-info/entry_points.txt,sha256=roa0PDgBueM1JPbRG0G2OSxzaN394OUL_oS9iEwVLBc,80
64
- afterpython-0.3.10.dist-info/METADATA,sha256=2sC2DKjDGAOvPkuoESl82akQUx27-qik117DYuKuIHE,6181
65
- afterpython-0.3.10.dist-info/RECORD,,
62
+ afterpython-0.3.11.dist-info/WHEEL,sha256=f5fWSvWsg5Knq5GWa6t1nJIug0Tqo69GqAWD_9LbBKw,81
63
+ afterpython-0.3.11.dist-info/entry_points.txt,sha256=roa0PDgBueM1JPbRG0G2OSxzaN394OUL_oS9iEwVLBc,80
64
+ afterpython-0.3.11.dist-info/METADATA,sha256=hc_faP_lCFJJAnGtyYz_sxcvtkDMC-y-engXV8oScDI,6181
65
+ afterpython-0.3.11.dist-info/RECORD,,