|
| 1 | +(downloading_deploying)= |
| 2 | + |
| 3 | +# Downloading and deploying Pyodide |
| 4 | + |
| 5 | +## Downloading Pyodide |
| 6 | + |
| 7 | +### CDN |
| 8 | + |
| 9 | +Pyodide packages, including the `pyodide.js` file, are available from the JsDelivr CDN, |
| 10 | + |
| 11 | +| channel | indexURL | Comments | REPL | |
| 12 | +| ------------------- | ------------------------------------------------ | ---------------------------------------------------------------------------------------- | -------------------------------------------------- | |
| 13 | +| Latest release | `https://cdn.jsdelivr.net/pyodide/v0.18.0/full/` | Recommended, cached by the browser | [link](https://pyodide.org/en/stable/console.html) | |
| 14 | +| Dev (`main` branch) | `https://cdn.jsdelivr.net/pyodide/dev/full/` | Re-deployed for each commit on main, no browser caching, should only be used for testing | [link](https://pyodide.org/en/latest/console.html) | |
| 15 | + |
| 16 | +To access a particular file, append the file name to `indexURL`. For instance, |
| 17 | +`"${indexURL}pyodide.js"` in the case of `pyodide.js`. |
| 18 | + |
| 19 | +```{warning} |
| 20 | +The previous CDN `pyodide-cdn2.iodide.io` is deprecated and should not be used. |
| 21 | +``` |
| 22 | + |
| 23 | +### Github releases |
| 24 | + |
| 25 | +You can also download Pyodide packages from [Github |
| 26 | +releases](https://github.com/pyodide/pyodide/releases) |
| 27 | +(`pyodide-build-*.tar.bz2` file) serve them yourself, as explained in the |
| 28 | +following section. |
| 29 | + |
| 30 | +## Serving Pyodide packages |
| 31 | + |
| 32 | +If you built your Pyodide distribution or downloaded the release tarball |
| 33 | +you need to serve Pyodide files with appropriate headers. |
| 34 | + |
| 35 | +### Serving locally |
| 36 | + |
| 37 | +With Python 3.7.5+ you can serve Pyodide files locally by starting |
| 38 | + |
| 39 | +``` |
| 40 | +python -m http.server |
| 41 | +``` |
| 42 | + |
| 43 | +from the Pyodide distribution folder. |
| 44 | + |
| 45 | +Point your WebAssembly aware browser to |
| 46 | +[http://localhost:8000/console.html](http://localhost:8000/console.html) and open |
| 47 | +your browser console to see the output from Python via Pyodide! |
| 48 | + |
| 49 | +### Remote deployments |
| 50 | + |
| 51 | +Any solution that is able to host static files and correctly sets WASM |
| 52 | +MIME type, and CORS headers would work. For instance, you can use Github Pages |
| 53 | +or similar services. |
| 54 | + |
| 55 | +For additional suggestions for optimizing size and load times, see the [Emscripten |
| 56 | +documentation about deployments](https://emscripten.org/docs/compiling/Deploying-Pages.html). |
0 commit comments