Re: PyScript + VSCode (+Jupyter), EmscriptenForge, MambaLite, BinderLite (repo2jupyterlite), Datasette, ipycanvas + sphinx-jupyterlite

Wes Turner <[email protected]> Mon, 5 Sep 2022 20:07:18 -0400
Newsgroups gmane.comp.python.education
Message-ID <CACfEFw8yBn9yPOx_XMkQfGSencYoGkMBB3RgJK2SEtQLxq6zFQ@mail.gmail.com>
--===============0817268375041604556==
Content-Type: multipart/alternative; boundary="000000000000ae533405e7f6fc1f"

--000000000000ae533405e7f6fc1f
Content-Type: text/plain; charset="UTF-8"

"Support for PyScript & Brython"
https://github.com/microsoft/vscode-python/issues/19415

- https://marketplace.visualstudio.com/items?itemName=HardeepSingh.pyscript

Jupyter support in VSCode:
- https://code.visualstudio.com/docs/datascience/jupyter-notebooks

JupyterLite has p5 js support. Khan Academy CS curriculum has ProcessingJS,
which is basically p5 js.
What similar functionality exists in the python standard library? Does the
stdlib turtle module work in pyodide WASM (JupyterLite, PyScript,)?

***
Like matplotlib, but with vega-lite,
Altair charts are saveable to PNG, SVG for print/latexpdf.
https://altair-viz.github.io/user_guide/saving_charts.html

Annotated matplotlib:
https://twitter.com/__mharrison__/status/1562454754306826241

JupyterLite: https://jupyterlite.readthedocs.io/en/latest/ :

> Python kernel backed by Pyodide running in a Web Worker
>
> - Initial support for interactive visualization libraries such as altair,
bqplot, ipywidgets, matplotlib, and plotly

FWIU ipycanvas also works in JupyerLite:
Drawing paths > Path commands:
https://ipycanvas.readthedocs.io/en/latest/drawing_paths.html#path-commands

Src:
https://github.com/martinRenou/ipycanvas/blob/master/ipycanvas/canvas.py


***

The ipycanvas docs include JupyterLite w/
https://github.com/jupyterlite/jupyterlite-sphinx :

> JupyterLite Sphinx: A Sphinx extension that provides utilities for
embedding JupyterLite in your documentation


***

Datasette does static SQLite in WASM; now with JupyterLite as well:
https://datasette.io/plugins/datasette-jupyterlite

There are *-to-sqlite
utilities for all of the things; though pd.read_csv() can read from a
remote URL in WASM, potentially unreproducibly (next semester it 404s) and
without a requests_cache, just like in normal JupyterLab e.g. from
repo2docker: https://pypi.org/search/?q=to+sqlite
https://pypi.org/search/?q=datasette

***

> TIL about #EmscriptenForge, #MambaLite, #BinderLite (#repo2jupyterlite),
https://github.com/emscripten-forge/recipes

> Tools to pack a conda / mamba environment into a JS & WASM bundle
https://github.com/emscripten-forge/empack
>
> ```bash
empack pack env --env-prefix /path/to/env --outname python_data --config
/path/to/config.yaml
```
>
> This will generate two files python_data.js and python_data.data that you
can use in the browser. A sample config is located in
tests/empack_test_config.yaml


https://github.com/emscripten-forge/requests-wasm-polyfill :
> Drop-in replacement for the requests library for wasm python
> Note that these only work when running under a web-worker, as it's making
blocking HTTP requests which are not allowed in the main thread.

"Polyfills"; just like JS

On Mon, Sep 5, 2022, 2:42 PM kirby urner <[email protected]> wrote:

>
> https://youtu.be/obZqST6mBn8  (2 mins 41 secs)
>
> My first video on PyScript.
>
> Alludes to other topics in my Python for High School stuff.
>
> https://github.com/4dsolutions/elite_school/blob/master/PY4HS.ipynb
>
> Kirby
>
> _______________________________________________
> Edu-sig mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/edu-sig.python.org/
> Member address: [email protected]
>

--000000000000ae533405e7f6fc1f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">&quot;Support for PyScript &amp; Brython&quot; <a href=3D=
"https://github.com/microsoft/vscode-python/issues/19415">https://github.co=
m/microsoft/vscode-python/issues/19415</a><div dir=3D"auto"><br></div><div =
dir=3D"auto">- <a href=3D"https://marketplace.visualstudio.com/items?itemNa=
me=3DHardeepSingh.pyscript">https://marketplace.visualstudio.com/items?item=
Name=3DHardeepSingh.pyscript</a></div><div dir=3D"auto"><br></div><div dir=
=3D"auto">Jupyter support in VSCode:</div><div dir=3D"auto">- <a href=3D"ht=
tps://code.visualstudio.com/docs/datascience/jupyter-notebooks">https://cod=
e.visualstudio.com/docs/datascience/jupyter-notebooks</a></div><div dir=3D"=
auto"><br></div><div dir=3D"auto">JupyterLite has p5 js support. Khan Acade=
my CS curriculum has ProcessingJS, which is basically p5 js.</div><div dir=
=3D"auto">What similar functionality exists in the python standard library?=
 Does the stdlib turtle module work in pyodide WASM (JupyterLite, PyScript,=
)?</div><div dir=3D"auto"><br></div><div dir=3D"auto">***</div><div dir=3D"=
auto">Like matplotlib, but with vega-lite,</div><div dir=3D"auto">Altair ch=
arts are saveable to PNG, SVG for print/latexpdf. <a href=3D"https://altair=
-viz.github.io/user_guide/saving_charts.html">https://altair-viz.github.io/=
user_guide/saving_charts.html</a></div><div dir=3D"auto"><br></div><div dir=
=3D"auto">Annotated matplotlib:=C2=A0 <a href=3D"https://twitter.com/__mhar=
rison__/status/1562454754306826241">https://twitter.com/__mharrison__/statu=
s/1562454754306826241</a></div><div dir=3D"auto"><br></div><div dir=3D"auto=
">JupyterLite: <a href=3D"https://jupyterlite.readthedocs.io/en/latest/">ht=
tps://jupyterlite.readthedocs.io/en/latest/</a> :</div><div dir=3D"auto"><b=
r></div><div dir=3D"auto">&gt; Python kernel backed by Pyodide running in a=
 Web Worker</div><div dir=3D"auto">&gt;</div><div dir=3D"auto">&gt; - Initi=
al support for interactive visualization libraries such as altair, bqplot, =
ipywidgets, matplotlib, and plotly</div><div dir=3D"auto"><br></div><div di=
r=3D"auto">FWIU ipycanvas also works in JupyerLite:</div><div dir=3D"auto">=
Drawing paths &gt; Path commands: <a href=3D"https://ipycanvas.readthedocs.=
io/en/latest/drawing_paths.html#path-commands">https://ipycanvas.readthedoc=
s.io/en/latest/drawing_paths.html#path-commands</a></div><div dir=3D"auto">=
<br></div><div dir=3D"auto">Src: <a href=3D"https://github.com/martinRenou/=
ipycanvas/blob/master/ipycanvas/canvas.py">https://github.com/martinRenou/i=
pycanvas/blob/master/ipycanvas/canvas.py</a></div><div dir=3D"auto"><br></d=
iv><div dir=3D"auto"><br></div><div dir=3D"auto">***</div><div dir=3D"auto"=
><br></div><div dir=3D"auto">The ipycanvas docs include JupyterLite w/=C2=
=A0 <a href=3D"https://github.com/jupyterlite/jupyterlite-sphinx">https://g=
ithub.com/jupyterlite/jupyterlite-sphinx</a> :</div><div dir=3D"auto"><br><=
/div><div dir=3D"auto">&gt; JupyterLite Sphinx: A Sphinx extension that pro=
vides utilities for embedding JupyterLite in your documentation</div><div d=
ir=3D"auto"><br></div><div dir=3D"auto"><br></div><div dir=3D"auto">***</di=
v><div dir=3D"auto"><br></div><div dir=3D"auto">Datasette does static SQLit=
e in WASM; now with JupyterLite as well:=C2=A0</div><div dir=3D"auto"><a hr=
ef=3D"https://datasette.io/plugins/datasette-jupyterlite">https://datasette=
.io/plugins/datasette-jupyterlite</a></div><div dir=3D"auto"><br></div><div=
 dir=3D"auto">There are *-to-sqlite=C2=A0</div><div dir=3D"auto">utilities =
for all of the things; though pd.read_csv() can read from a remote URL in W=
ASM, potentially unreproducibly (next semester it 404s) and without a reque=
sts_cache, just like in normal JupyterLab e.g. from repo2docker: <a href=3D=
"https://pypi.org/search/?q=3Dto+sqlite">https://pypi.org/search/?q=3Dto+sq=
lite</a>=C2=A0 <a href=3D"https://pypi.org/search/?q=3Ddatasette">https://p=
ypi.org/search/?q=3Ddatasette</a></div><div dir=3D"auto"><br></div><div dir=
=3D"auto">***</div><div dir=3D"auto"><br></div><div dir=3D"auto">&gt; TIL a=
bout #EmscriptenForge, #MambaLite, #BinderLite (#repo2jupyterlite),</div><d=
iv dir=3D"auto"><a href=3D"https://github.com/emscripten-forge/recipes">htt=
ps://github.com/emscripten-forge/recipes</a></div><div dir=3D"auto"><br></d=
iv><div dir=3D"auto">&gt; Tools to pack a conda / mamba environment into a =
JS &amp; WASM bundle</div><div dir=3D"auto"><a href=3D"https://github.com/e=
mscripten-forge/empack">https://github.com/emscripten-forge/empack</a>=C2=
=A0</div><div dir=3D"auto">&gt;</div><div dir=3D"auto">&gt; ```bash</div><d=
iv dir=3D"auto">empack pack env --env-prefix /path/to/env --outname python_=
data  --config /path/to/config.yaml</div><div dir=3D"auto">```</div><div di=
r=3D"auto">&gt;</div><div dir=3D"auto">&gt; This will generate two files py=
thon_data.js and python_data.data that you can use in the browser. A sample=
 config is located in tests/empack_test_config.yaml</div><div dir=3D"auto">=
<br></div><div dir=3D"auto"><br></div><div dir=3D"auto"><a href=3D"https://=
github.com/emscripten-forge/requests-wasm-polyfill">https://github.com/emsc=
ripten-forge/requests-wasm-polyfill</a> :</div><div dir=3D"auto">&gt; Drop-=
in replacement for the requests library for wasm python</div><div dir=3D"au=
to">&gt; Note that these only work when running under a web-worker, as it&#=
39;s making blocking HTTP requests which are not allowed in the main thread=
.</div><div dir=3D"auto"><br></div><div dir=3D"auto">&quot;Polyfills&quot;;=
 just like JS</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" cl=
ass=3D"gmail_attr">On Mon, Sep 5, 2022, 2:42 PM kirby urner &lt;<a href=3D"=
mailto:[email protected]">[email protected]</a>&gt; wrote:<br></div=
><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_defaul=
t" style=3D"font-family:arial,helvetica,sans-serif;font-size:small"><br></d=
iv><div class=3D"gmail_default" style=3D"font-family:arial,helvetica,sans-s=
erif;font-size:small"><a href=3D"https://youtu.be/obZqST6mBn8" target=3D"_b=
lank" rel=3D"noreferrer">https://youtu.be/obZqST6mBn8</a>=C2=A0 (2 mins 41 =
secs)<br></div><div class=3D"gmail_default" style=3D"font-family:arial,helv=
etica,sans-serif;font-size:small"><br></div><div class=3D"gmail_default" st=
yle=3D"font-family:arial,helvetica,sans-serif;font-size:small">My first vid=
eo on PyScript.=C2=A0 <br></div><div class=3D"gmail_default" style=3D"font-=
family:arial,helvetica,sans-serif;font-size:small"><br></div><div class=3D"=
gmail_default" style=3D"font-family:arial,helvetica,sans-serif;font-size:sm=
all">Alludes to other topics in my Python for High School stuff.<br></div><=
div class=3D"gmail_default" style=3D"font-family:arial,helvetica,sans-serif=
;font-size:small"><br></div><div class=3D"gmail_default" style=3D"font-fami=
ly:arial,helvetica,sans-serif;font-size:small"><a href=3D"https://github.co=
m/4dsolutions/elite_school/blob/master/PY4HS.ipynb" target=3D"_blank" rel=
=3D"noreferrer">https://github.com/4dsolutions/elite_school/blob/master/PY4=
HS.ipynb</a></div><div class=3D"gmail_default" style=3D"font-family:arial,h=
elvetica,sans-serif;font-size:small"><br></div><div class=3D"gmail_default"=
 style=3D"font-family:arial,helvetica,sans-serif;font-size:small">Kirby</di=
v><div class=3D"gmail_default" style=3D"font-family:arial,helvetica,sans-se=
rif;font-size:small"><br></div></div>
_______________________________________________<br>
Edu-sig mailing list -- <a href=3D"mailto:[email protected]" target=3D"_bl=
ank" rel=3D"noreferrer">[email protected]</a><br>
To unsubscribe send an email to <a href=3D"mailto:[email protected]"=
 target=3D"_blank" rel=3D"noreferrer">[email protected]</a><br>
<a href=3D"https://mail.python.org/mailman3/lists/edu-sig.python.org/" rel=
=3D"noreferrer noreferrer" target=3D"_blank">https://mail.python.org/mailma=
n3/lists/edu-sig.python.org/</a><br>
Member address: <a href=3D"mailto:[email protected]" target=3D"_blank" r=
el=3D"noreferrer">[email protected]</a><br>
</blockquote></div>

--000000000000ae533405e7f6fc1f--

--===============0817268375041604556==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Edu-sig mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/edu-sig.python.org/
Member address: [email protected]

--===============0817268375041604556==--