Pyodide is a Python distribution for the browser and Node.js based on WebAssembly
Go to file
Michael Droettboom 1799e45525 Go back to tags only 2019-05-31 15:50:59 -04:00
.circleci Go back to tags only 2019-05-31 15:50:59 -04:00
.netlify Automated deployment to Netlify (#451) 2019-05-31 14:39:52 -04:00
CLAPACK Use -Os and small INLINING_LIMIT for files liked with LAPACK 2018-11-15 13:24:27 +01:00
benchmark Build the _decimal C module 2019-02-25 11:29:59 -05:00
bin Explicitly use python3 for pyodide_build 2019-01-09 20:56:46 +05:30
cpython Add crypt module (#369) 2019-04-04 13:55:15 -04:00
docs Fix #422: Correct loadedPackage -> loadedPackages (#426) 2019-05-16 10:03:34 -04:00
emsdk Upgrade to emscripten 1.38.30 (#374) 2019-04-04 07:57:47 -04:00
lz4 Use LZ4 filesystem compression, using the canonical C implementation 2018-09-19 16:44:54 -04:00
packages Loading wheels from PyPI (#147) 2019-05-03 13:43:31 -04:00
pyodide_build Loading wheels from PyPI (#147) 2019-05-03 13:43:31 -04:00
six Add documentation to new build tools. 2018-06-22 10:22:00 -04:00
src Automated deployment to Netlify (#451) 2019-05-31 14:39:52 -04:00
test Loading wheels from PyPI (#147) 2019-05-03 13:43:31 -04:00
tools Ignore the gfortran link 2019-01-23 19:58:45 -05:00
.bumpversion.cfg Bump version: 0.11.0 → 0.12.0 2019-05-03 13:45:55 -04:00
.clang-format Remove keys from .clang-format 2018-11-13 09:46:24 -05:00
.editorconfig Fix #71: Upgrade to Python 3.7 2018-09-06 10:56:33 -04:00
.gitignore ignore .vscode (#361) 2019-03-26 08:49:53 -04:00
CHANGELOG.md Update CHANGELOG 2019-05-03 13:45:50 -04:00
CODE-OF-CONDUCT.md Update link to recurse center code of conduct 2018-07-18 18:52:18 -04:00
CONTRIBUTING.md Add linting 2018-06-14 14:19:08 -04:00
Dockerfile CLAPACK setup 2018-10-31 15:12:43 +01:00
LICENSE Initial commit 2018-02-23 14:21:29 -05:00
Makefile Enable building sqlite3 into cpython (#352) 2019-03-26 08:44:21 -04:00
Makefile.envs Upgrade to emscripten 1.38.30 (#374) 2019-04-04 07:57:47 -04:00
README.md Update Instructions for Building Pyodide (#425) 2019-05-16 10:03:18 -04:00
remove_modules.txt Enable building sqlite3 into cpython (#352) 2019-03-26 08:44:21 -04:00
run_docker Allow configuring run_docker ports using env vars 2019-03-21 07:49:50 -07:00
setup.cfg Rename to dryrun, add docstring and doctest 2018-10-23 12:13:59 +02:00

README.md

Pyodide

Build Status

The Python scientific stack, compiled to WebAssembly.

It provides transparent conversion of objects between Javascript and Python. When inside a browser, this means Python has full access to the Web APIs.

While closely related to the iodide project, Pyodide may be used standalone in any context where you want to run Python inside a web browser.

For more information, see the demo and the documentation.

Building

Building is easiest on Linux. For other platforms, we recommend using the Docker image (described below) to build Pyodide.

Make sure the prerequisites for emsdk are installed. Pyodide will build a custom, patched version of emsdk, so there is no need to build it yourself prior.

Additional build prerequisites are:

  • A working native compiler toolchain, enough to build CPython.
  • A native Python 3.7 to run the build scripts.
  • PyYAML
  • lessc to compile less to css.
  • uglifyjs to minify Javascript builds.
  • ccache (optional) recommended for much faster rebuilds.

make

Using Docker

We provide a Debian-based Docker image on Docker Hub with the dependencies already installed to make it easier to build Pyodide.

  1. Install Docker

  2. From a git checkout of Pyodide, run ./run_docker

  3. Run make to build.

If running make deterministically stops at one point in each subsequent try, increasing the maximum RAM usage available to the docker container might help [This is different from the physical RAM capacity inside the system]. Ideally, at least 3 GB of RAM should be available to the docker container to build pyodide smoothly. These settings can be changed via Docker Preferences [See here].

You can edit the files in your source checkout on your host machine, and then repeatedly run make inside the Docker environment to test your changes.

Testing

Install the following dependencies into the default Python installation:

pip install pytest selenium pytest-instafail

Install geckodriver and chromedriver somewhere on your PATH.

pytest test/

Manual Testing

The port 8000 of the docker environment and the host system are automatically binded when ./run_docker is run.

This can be used to test the pyodide builds running within the docker environment using external browser programs on the host system.

To do this, simply run ./bin/pyodide serve

This serves the build directory of the pyodide project on port 8000.

  • To serve a different directory, use the --build_dir argument followed by the path of the directory
  • To serve on a different port, use the --port argument followed by the desired port number

Make sure that the port passed in --port argument is same as the one defined as DOCKER_PORT in the run_docker script.

Once the webserver is running, for simple interactive testing, visit the URL http://localhost:8000/console.html

Benchmarking

Install the same dependencies as for testing.

make benchmark

Linting

Python is linted with flake8. C and Javascript are linted with clang-format.

make lint