Skip to content

Commit e09fa17

Browse files
authored
Cleanup PyScript renderer & use Bun for building JS (#254)
- Switch to `Bun` for building JS - Minor cleanup to pyscript renderer - Revert pyscript version to 0.5 due to [bugs](pyscript/pyscript#2228)
1 parent 7948ac4 commit e09fa17

23 files changed

+135
-3575
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ end_of_line = lf
1414
indent_size = 4
1515
max_line_length = 120
1616

17+
[*.yml]
18+
indent_size = 4
19+
1720
[*.md]
1821
indent_size = 4
1922

2023
[*.html]
24+
indent_size = 4
2125
max_line_length = off
2226

2327
[*.js]

.github/workflows/publish-develop-docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
- uses: actions/checkout@v4
1212
with:
1313
fetch-depth: 0
14+
- uses: oven-sh/setup-bun@v2
15+
with:
16+
bun-version: latest
1417
- uses: actions/setup-python@v5
1518
with:
1619
python-version: 3.x

.github/workflows/publish-py.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v4
15+
- uses: oven-sh/setup-bun@v2
16+
with:
17+
bun-version: latest
1518
- name: Set up Python
1619
uses: actions/setup-python@v5
1720
with:

.github/workflows/publish-release-docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
- uses: actions/checkout@v4
1212
with:
1313
fetch-depth: 0
14+
- uses: oven-sh/setup-bun@v2
15+
with:
16+
bun-version: latest
1417
- uses: actions/setup-python@v5
1518
with:
1619
python-version: 3.x

.github/workflows/test-docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717
- uses: actions/checkout@v4
1818
with:
1919
fetch-depth: 0
20+
- uses: oven-sh/setup-bun@v2
21+
with:
22+
bun-version: latest
2023
- uses: actions/setup-python@v5
2124
with:
2225
python-version: 3.x

.github/workflows/test-src.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ jobs:
1818
python-version: ["3.9", "3.10", "3.11", "3.12"]
1919
steps:
2020
- uses: actions/checkout@v4
21+
- uses: oven-sh/setup-bun@v2
22+
with:
23+
bun-version: latest
2124
- name: Use Python ${{ matrix.python-version }}
2225
uses: actions/setup-python@v5
2326
with:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% pyscript_setup config='{"interpreter":"/static/pyodide/pyodide.mjs"}' %}

docs/src/about/code.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
If you plan to make code changes to this repository, you will need to install the following dependencies first:
2020

2121
- [Python 3.9+](https://www.python.org/downloads/)
22+
- [Bun](https://bun.sh/)
2223
- [Git](https://git-scm.com/downloads)
2324

2425
Once done, you should clone this repository:

docs/src/reference/template-tag.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,3 +391,17 @@ You can optionally use this tag to configure the current PyScript environment. F
391391
```python
392392
{% include "../../examples/python/pyscript-setup-config-object.py" %}
393393
```
394+
395+
??? question "Can I use a local interpreter for PyScript?"
396+
397+
Yes, you can set up a local interpreter by following PyScript's [standard documentation](https://docs.pyscript.net/latest/user-guide/offline/#local-pyodide-packages).
398+
399+
To summarize,
400+
401+
1. Download the latest Pyodide bundle from the [Pyodide GitHub releases page](https://github.com/pyodide/pyodide/releases) (for example `pyodide-0.26.3.tar.bz2`).
402+
2. Extract the contents of the bundle to your project's static files.
403+
3. Configure your `#!jinja {% pyscript_setup %}` template tag to use `pyodide` as an interpreter.
404+
405+
```jinja linenums="0"
406+
{% include "../../examples/html/pyscript-setup-local-interpreter.html" %}
407+
```

noxfile.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ def test_python(session: Session) -> None:
3131
settings_files = glob(settings_glob)
3232
assert settings_files, f"No Django settings files found at '{settings_glob}'!"
3333
for settings_file in settings_files:
34-
settings_module = settings_file.strip(".py").replace("/", ".").replace("\\", ".")
34+
settings_module = (
35+
settings_file.strip(".py").replace("/", ".").replace("\\", ".")
36+
)
3537
session.run(
3638
"python",
3739
"manage.py",
3840
"test",
3941
*posargs,
40-
"-v",
41-
"2",
4242
"--settings",
4343
settings_module,
4444
)
@@ -62,8 +62,8 @@ def test_style(session: Session) -> None:
6262
def test_javascript(session: Session) -> None:
6363
install_requirements_file(session, "test-env")
6464
session.chdir(ROOT_DIR / "src" / "js")
65-
session.run("python", "-m", "nodejs.npm", "install", external=True)
66-
session.run("python", "-m", "nodejs.npm", "run", "check")
65+
session.run("bun", "install", external=True)
66+
session.run("bun", "run", "check", external=True)
6767

6868

6969
def install_requirements_file(session: Session, name: str) -> None:

0 commit comments

Comments
 (0)