Pyodide is a Python distribution for the browser and Node.js based on WebAssembly
Go to file
Roman Yurchak f3f596f0c1 Do no build CLAPACK if PYODIDE_PACKAGES is defined 2020-05-09 12:40:35 +02:00
.circleci Add build-test-minimal CI job 2020-05-09 01:52:25 +02:00
.netlify Automated deployment to Netlify (#451) 2019-05-31 14:39:52 -04:00
CLAPACK Ensure arith.h in libf2c gets built by touching it 2019-10-21 12:27:18 -04:00
benchmark MAINT Refactor benchmark script (#472) 2019-07-01 08:38:18 -04:00
bin Explicitly use python3 for pyodide_build 2019-01-09 20:56:46 +05:30
cpython ENH Upgrade cpython to 3.7.4 (#625) 2020-03-25 12:31:12 +01:00
docs Do no build CLAPACK if PYODIDE_PACKAGES is defined 2020-05-09 12:40:35 +02:00
emsdk Update to use sdk-fastcomp-tag-<version> for emscripten (#589) 2019-12-31 12:09:39 -05:00
jedi Add support for completions based on jedi (#504) 2019-08-14 10:16:12 -04:00
lz4 Use LZ4 filesystem compression, using the canonical C implementation 2018-09-19 16:44:54 -04:00
packages Add mechanism to build a subset of packages 2020-05-09 01:28:44 +02:00
parso Add support for completions based on jedi (#504) 2019-08-14 10:16:12 -04:00
pyodide_build Refactor 2020-05-09 12:32:10 +02:00
six Add documentation to new build tools. 2018-06-22 10:22:00 -04:00
src Fall back to WebAssembly.compile on mime type error (#628) 2020-03-30 19:28:34 +02:00
test Refactor 2020-05-09 12:32:10 +02:00
tools Document and check for a few more things when building pyodide (#593) 2020-01-02 17:42:43 -05:00
.bumpversion.cfg Bump version: 0.13.1 → 0.14.0 2019-08-14 10:16:53 -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 Add dependency check for the builds. (#568) 2019-11-19 16:51:45 -05:00
.readthedocs.yml Adds Sphinx documentation build (#474) 2019-06-22 18:22:38 -04:00
CHANGELOG.md allow micropip to function in a web worker (#632) 2020-04-15 10:28:59 -04:00
CODE-OF-CONDUCT.md Update link to recurse center code of conduct 2018-07-18 18:52:18 -04:00
CONTRIBUTING.md Adds Sphinx documentation build (#474) 2019-06-22 18:22:38 -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 Do no build CLAPACK if PYODIDE_PACKAGES is defined 2020-05-09 12:40:35 +02:00
Makefile.envs ENH Upgrade cpython to 3.7.4 (#625) 2020-03-25 12:31:12 +01:00
README.md Document and check for a few more things when building pyodide (#593) 2020-01-02 17:42:43 -05:00
conftest.py Increase the selenium timeout (#607) 2020-03-04 13:16:40 +01:00
pytest.ini MAINT Move package tests under packages/ dir (#471) 2019-06-19 14:26:08 -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

What is Pyodide? | Try Pyodide | Getting Started | Contributing | License

Pyodide

Build Status Documentation Status

The Python scientific stack, compiled to WebAssembly.

Try Pyodide and Iodide in your browser

What is Pyodide?

Pyodide brings the Python runtime to the browser via WebAssembly, along with the Python scientific stack including NumPy, Pandas, Matplotlib, parts of SciPy, and NetworkX. The packages directory lists over 35 packages which are currently available.

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

While closely related to the iodide project, a tool for literate scientific computing and communication for the web, Pyodide goes beyond running in a notebook environment. To maximize the flexibility of the modern web, Pyodide may be used standalone in any context where you want to run Python inside a web browser.

Try Pyodide (no installation needed)

For more information, try the demo and look through the documentation.

Getting Started

Pyodide offers three different ways to get started depending on your needs and technical resources. These include:

  • Download a pre-built version (the quickest way to get started)
  • Build Pyodide from source (this method requires installing prerequistes and using make. Primarily for Linux users who want to experiment or contribute back to the project.)
  • Use a Docker image (recommended for Windows and macOS users and for Linux users who prefer a Debian-based Docker image on Docker Hub with the dependencies already installed)

Download a pre-built version

Pre-built versions of Pyodide may be downloaded from this repository's releases page.

Building from source

Building is easiest on Linux and relatively straightforward on Mac. For Windows, we currently 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.
  • gfortran (GNU Fortran 95 compiler)
  • f2c
  • ccache (optional) highly recommended for much faster rebuilds.

On Mac, you will also need:

  • Homebrew for installing dependencies
  • System libraries in the root directory (sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / should do it, see https://github.com/pyenv/pyenv/issues/1219#issuecomment-428305417)
  • coreutils for md5sum and other essential Unix utilities (brew install coreutils)
  • cmake (brew install cmake)
  • pkg-config (brew install pkg-config)
  • openssl (brew install openssl)
  • gfortran (brew cask install gfortran)
  • f2c: Install wget (brew install wget), and then run the buildf2c script from the root directory (sudo ./tools/buildf2c)

Build using make

After installing the build prerequisites, run from the command line:

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. Note that building from the Docker image is very slow on Mac, building on the host machine is preferred if at all possible.

  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.

Contributing

Please view the CONTRIBUTING document for tips on filing issues, making changes, and submitting pull requests. The following sections describe how to run tests, run Pyodide benchmarks, and lint the source code.

Testing

Install the following dependencies into the default Python installation:

pip install pytest selenium pytest-instafail

Install geckodriver and chromedriver and check that they are in your PATH.

Automated testing

To run the pytest suite of tests, type on the command line:

pytest test/ packages/

Manual interactive testing

To run manual interactive tests, a docker environment and a webserver will be used.

  1. Bind port 8000 for testing. To automatically bind port 8000 of the docker environment and the host system, run: ./run_docker

  2. Now, 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, run: ./bin/pyodide serve

  3. 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.
  4. Once the webserver is running, simple interactive testing can be run by visiting this URL: http://localhost:8000/console.html

Benchmarking

To run common benchmarks to understand Pyodide's performance, begin by installing the same prerequisites as for testing. Then run:

make benchmark

Linting

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

To lint the code, run:

make lint

License

Pyodide uses the Mozilla Public License Version 2.0. See the LICENSE file for more details.


What is Pyodide? | Try Pyodide | Getting Started | Contributing | License | Back to top