-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate pyodide repodata, add more mocks #27
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6266007
Generate pyodide repodata, add more mocks
bollwyvl 5817a36
tighten up schema, improve piplite a little
bollwyvl 4b239b0
add pytest-xdist
bollwyvl c370e55
move install_on_import to pyodide, add package.json schema for pyodid…
bollwyvl 1805a4a
don't require built labextension
bollwyvl 04131a9
build example site against pyodide-core with repodata
bollwyvl 01f7212
omit repo tests from coverage
bollwyvl 52c17ce
bump coverage down further, update intro with more info and links
bollwyvl a58a42a
move python to src to avoid import confusion
bollwyvl bd79675
add totality check
bollwyvl 9f4fd07
linting
bollwyvl 607ab50
apply more ruff
bollwyvl a66fe3c
ensure repodata.json not added to output
bollwyvl 0238adc
move dev to quickstart
bollwyvl bc0e979
jlpm dev in rtd
bollwyvl 6a1e758
merge upstream
bollwyvl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,234 @@ | ||
{ | ||
"metadata": { | ||
"kernelspec": { | ||
"name": "python", | ||
"display_name": "Python (Pyodide)", | ||
"language": "python" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "python", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8" | ||
} | ||
}, | ||
"nbformat_minor": 5, | ||
"nbformat": 4, | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"source": "# Introduction to `jupyterlite-pyodide-kernel`\n\n`jupyterlite-pyodide-kernel` extends [JupyterLite](https://jupyterlite.rtfd.io) with a Python 3 kernel, powered by [Pyodide](https://pyodide.org/).", | ||
"metadata": {}, | ||
"id": "ab1dc4ef-36ae-4893-8fb4-474440fabc8a" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": "## Visualizing data in a Notebook ✨\n\nBelow is an example of a code cell. We'll visualize some simple data using two popular\npackages in Python. We'll use [NumPy](https://numpy.org/) to create some random data,\nand [Matplotlib](https://matplotlib.org) to visualize it.\n\nNote how the code and the results of running the code are bundled together.", | ||
"metadata": {}, | ||
"id": "a6372e17-bf46-48c5-90a3-bdd6236e376e" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": "from matplotlib import pyplot as plt\nimport numpy as np\n\n# Generate 100 random data points along 3 dimensions\nx, y, scale = np.random.randn(3, 100)\nfig, ax = plt.subplots()\n\n# Map each onto a scatterplot we'll create with Matplotlib\nax.scatter(x=x, y=y, c=scale, s=np.abs(scale) * 500)\nax.set(title=\"Some random data, created with JupyterLab!\")\nplt.show()", | ||
"metadata": { | ||
"trusted": true | ||
}, | ||
"execution_count": null, | ||
"outputs": [], | ||
"id": "fe55883a-6887-43dd-9498-5333a51799e2" | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"source": "## Interact with Widgets 🎛️\n\n[Jupyter Widgets](https://jupyter.org/widgets) power rich interactivity between users of Jupyter clients and Jupyter kernels. With `jupyterlab_widgets` installed, all of the [core widgets](https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20List.html) will work in `jupyterlite-pyodide-kernel`, as do many third-party packages.", | ||
"metadata": {}, | ||
"id": "61bd8fda-3e36-4910-b319-668e8843f322" | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": "%pip install ipywidgets\nfrom ipywidgets import *\nslider = FloatSlider()\nreadout = FloatText()\njslink((slider, \"value\"), (readout, \"value\"))\nHBox([slider, readout])", | ||
"metadata": { | ||
"trusted": true | ||
}, | ||
"execution_count": null, | ||
"outputs": [], | ||
"id": "b034c439-aea0-4880-9118-75f7a2b1092a" | ||
} | ||
] | ||
} | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ab1dc4ef-36ae-4893-8fb4-474440fabc8a", | ||
"metadata": {}, | ||
"source": [ | ||
"# Introduction to `jupyterlite-pyodide-kernel`\n", | ||
"\n", | ||
"[`jupyterlite-pyodide-kernel`](https://github.com/jupyterlite/pyodide-kernel) extends [JupyterLite](https://jupyterlite.rtfd.io) with a Python 3 kernel, powered by [Pyodide](https://pyodide.org/) and [IPython](https://ipython.readthedocs.io).\n", | ||
"\n", | ||
"> _ℹ️ Use the ▸ button, or <kbd>shift+enter</kbd> to run cells below_" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "db046898-d539-444b-a1e2-e95b4b40d989", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import this" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "edd8be2c-16a1-47c5-ae5d-7b70ff3938b2", | ||
"metadata": {}, | ||
"source": [ | ||
"### Example: Interactive Widgets\n", | ||
"\n", | ||
"[Jupyter Widgets](https://jupyter.org/widgets) power rich interactivity between users of Jupyter clients and Jupyter kernels. With `jupyterlab_widgets` installed, all of the [core widgets](https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20List.html) will work in `jupyterlite-pyodide-kernel`, as do many third-party packages.\n", | ||
"\n", | ||
"> ⚠️ _`ipywidgets` _and_ `jupyterlab_widgets` were included at **build time** of this site, and are **not** available by default when installing `jupyterlite-pyodide-kernel`._" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "b034c439-aea0-4880-9118-75f7a2b1092a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from ipywidgets import *\n", | ||
"slider = FloatSlider()\n", | ||
"readout = FloatText()\n", | ||
"jslink((slider, \"value\"), (readout, \"value\"))\n", | ||
"HBox([slider, readout])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "cd2f8599-4985-4db7-8f75-e447cb4801fc", | ||
"metadata": {}, | ||
"source": [ | ||
"## What is JupyterLite?\n", | ||
"\n", | ||
"JupyterLite is a **limited** implementation of the [Jupyter architecture](https://jupyter.org).\n", | ||
"\n", | ||
"Like the tradtional JupyterLab client/server stack of **tools for interactive computing**, it provides:\n", | ||
"- a subset of the [Jupyter **Server** API](https://jupyter-server.readthedocs.io/en/latest/developers/rest-api.html), implemented in JavaScript\n", | ||
"- browser-based **kernels**, like JupyterLite Pyodide Kernel, which run entirely in the browser\n", | ||
"- a Jupyter browser **client** based on [JupyterLab](https://jupyterlab.readthedocs.io) and many of its [extensions](https://pypi.org/search/?q=&o=&c=Framework+%3A%3A+Jupyter+%3A%3A+JupyterLab+%3A%3A+Extensions+%3A%3A+Prebuilt)\n", | ||
"- the Jupyter [Notebook **format**](https://nbformat.readthedocs.io)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b559d0e6-03bf-4706-b5f5-4fd1ef5c0a36", | ||
"metadata": {}, | ||
"source": [ | ||
"## What is Pyodide?\n", | ||
"\n", | ||
"Pyodide is a distribution of [CPython](https://github.com/python/cpython), compiled to [WebAssembly](https://webassembly.org) with [Emscripten](https://emscripten.org) which runs entirely within the browser." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ddcc1b90-cbaf-422b-915e-448be20617cd", | ||
"metadata": {}, | ||
"source": [ | ||
"## What _can't_ it do?\n", | ||
"\n", | ||
"While a very broad subset of the CPython standard library, and much of the open source, scientific Python ecosystem are available, there are some limitation.\n", | ||
"\n", | ||
"The best way to find out is to **try it out**! However, some known implementation-level limitations are listed below." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "f2a6e1fc-589f-46f5-aef5-1878c476a213", | ||
"metadata": {}, | ||
"source": [ | ||
"### Differences from CPython\n", | ||
"\n", | ||
"A number of aspects of the underlying Python implementation that don't work the same way as their upstream counterparts, if at all. Uses of these features will need to be updated, or put behind some check.\n", | ||
"\n", | ||
"- no threads\n", | ||
"- no subprocesses\n", | ||
"- no custom event asynchronous loops\n", | ||
"- package `data_files` are not installed\n", | ||
"- some blocking features are made asynchronous\n", | ||
" - `input` must be `await`ed\n", | ||
" - the `urllib` family of HTTP features don't work\n", | ||
" - though [pyodide-http](https://github.com/koenvo/pyodide-http) can be explicitly installed, imported and used" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "961bb18f-954b-4624-bf85-774d451addec", | ||
"metadata": {}, | ||
"source": [ | ||
"### Differences from `IPython` and `ipykernel`\n", | ||
"\n", | ||
"`jupyterlite-pyodide-kernel` ships a _shim_ of `ipykernel`, and changes a number of features in `ipython`\n", | ||
"\n", | ||
"- many [magics](https://ipython.readthedocs.io/en/stable/interactive/magics.html) don't work" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "896da1d0-f51b-4c76-a25a-c448455e4960", | ||
"metadata": {}, | ||
"source": [ | ||
"### Differences from Pyodide\n", | ||
"Because `jupyterlite-pyodide-kernel` runs inside a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers), a number of features don't work (yet).\n", | ||
"\n", | ||
"- no access to the browser's DOM\n", | ||
" - in particular, the Pyodide [matplotlib](https://github.com/pyodide/matplotlib-pyodide) backend will not work" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "75187813-fe26-47d6-84c2-eb5f4ac4bd91", | ||
"metadata": {}, | ||
"source": [ | ||
"## Where are all the Pyodide packages?\n", | ||
"\n", | ||
"This site follows the pattern for an [offline site](https://jupyterlite.readthedocs.io/en/0.1.0-beta/howto/configure/advanced/offline.html) based on a minimal, but fully self-contained, distribution of Pyodide. \n", | ||
"\n", | ||
"This means:\n", | ||
"- no additional resources are loaded from any other sites on the internet\n", | ||
" - serving from a content delivery network (CDN) is often faster, but _could_ disappear or change in the future \n", | ||
"- only the Python 3.10 standard library is available by default\n", | ||
"\n", | ||
"> ℹ️ For a more full-featured site with full Pyodide distributions, hosted from a CDN, see: \n", | ||
">\n", | ||
"> - the JupyterLite [documentation](https://jupyterlite.readthedocs.io) on [ReadTheDocs](https://jupyterlite.readthedocs.io/en/0.1.0-beta/reference/demo.html)\n", | ||
"> - the JupyterLite [demo](https://jupyterlite.github.io/demo) on [GitHub Pages](https://jupyterlite.readthedocs.io/en/0.1.0-beta/quickstart/deploy.html)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "5aaff9a8-9dfa-4180-8c9f-a2930557b3b2", | ||
"metadata": {}, | ||
"source": [ | ||
"## How do I use more Python packages?\n", | ||
"\n", | ||
"Simple python packages can be installed at runtime through one of the following methods.\n", | ||
"\n", | ||
"> ℹ️ Learn more on the [JupyterLite documentation](https://jupyterlite.readthedocs.io/en/latest/howto/python/packages.html), including how to make more packages available." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "4a9ffff0-e38c-47cf-b991-40dd17359b0c", | ||
"metadata": {}, | ||
"source": [ | ||
"### At runtime\n", | ||
"\n", | ||
"Packages not added (or known of) at build time can be imported with the [`%pip`](https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-pip) magic. This gives site visitors the freedom to explore beyond what a site builder even imagined at build time." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "2154019e-bd81-4313-a88a-445c5cf673f9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%pip install -q emoji" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "68b2607f-035c-48f9-ab21-316228085644", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import emoji\n", | ||
"b, m, s = \":badger:\", \":mushroom:\", \":snake:\"\n", | ||
"emoji.emojize(3 * (b * 12 + m * 2) + s * 3)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "58aa75f7-6f13-4c08-a83d-2b776116db7e", | ||
"metadata": {}, | ||
"source": [ | ||
"## How do I use more client extension packages?\n", | ||
"\n", | ||
"Some python packages, like all Jupyter widgets, will require client extensions, and need to be available when the site loads for a site visitor.\n", | ||
"\n", | ||
"Any number of JupyterLab [extensions]() can be [added at **build time**](https://jupyterlite.readthedocs.io/en/latest/howto/configure/simple_extensions.html), but not all will be compatible:\n", | ||
"\n", | ||
"- some extensions require a [Jupyter Server extension](https://jupyter-server.readthedocs.io/en/latest/developers/extensions.html)\n", | ||
" - it is _possible_ to [extend the JupyterLite server](https://jupyterlite.readthedocs.io/en/latest/howto/extensions/server.html)\n", | ||
"- some extensions require a different version of JupyterLab than the one JupyterLite is based on" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.0" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to move this folder in this PR? Are we expected more Python packages to be added to the repo later?
Would need to check how the releaser handles that. It probably breaks it without extra config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to keep
jupyterlite_pyodider_kernel
to the top-level for now until we really need to move it down to a nestedsrc
folder or similar.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
src
layout is widely used in a lot of packages, but i'll grant i haven't used it with the releaser.This avoids the possibility of it shadowing the as-installed package in
site-packages
. For some of the coverage stuff to work, it took weird junk like deleting the source and forcing a non--e .
install.This layout is supported by the all the build backends at this point, and releaser probably needs to be updated, if it can't yet do that.
It is weird that PEP 621 doesn't have a canonical place that information, but that's the brave new world.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. For now it's probably just going to create more issues. Happy to reconsider it if we track that in another issue. So the releaser config can properly be handled.
But for now it would be nice to keep it at the top-level so we can continue making releases (also it's not really related to the main change of this PR).