2018-02-24 17:52:47 +00:00
|
|
|
# Pyodide
|
|
|
|
|
2018-06-05 01:11:32 +00:00
|
|
|
[![Build Status](https://circleci.com/gh/iodide-project/pyodide.png)](https://circleci.com/gh/iodide-project/pyodide)
|
2018-03-30 18:10:03 +00:00
|
|
|
|
2018-06-07 19:50:53 +00:00
|
|
|
The Python scientific stack, compiled to WebAssembly.
|
|
|
|
|
2018-06-21 15:19:34 +00:00
|
|
|
It provides transparent conversion of objects between Javascript and Python.
|
|
|
|
When inside a browser, this means Python has full access to the Web APIs.
|
2018-02-23 19:34:33 +00:00
|
|
|
|
2018-06-22 18:54:59 +00:00
|
|
|
**While closely related to the [iodide project](https://iodide.io), Pyodide may
|
|
|
|
be used standalone in any context where you want to run Python inside a web
|
|
|
|
browser.**
|
|
|
|
|
2018-10-29 09:22:58 +00:00
|
|
|
For more information, see [the demo](https://iodide.io/pyodide-demo/python.html) and the
|
|
|
|
[documentation](https://github.com/iodide-project/pyodide/tree/master/docs).
|
2018-06-07 19:43:04 +00:00
|
|
|
|
2018-02-23 19:34:33 +00:00
|
|
|
# Building
|
|
|
|
|
2018-10-08 19:33:33 +00:00
|
|
|
Building is easiest on Linux. For other platforms, we recommend using
|
|
|
|
the Docker image (described below) to build Pyodide.
|
2018-02-23 19:34:33 +00:00
|
|
|
|
2018-06-21 15:19:34 +00:00
|
|
|
Make sure the prerequisites for [emsdk](https://github.com/juj/emsdk) are
|
|
|
|
installed. Pyodide will build a custom, patched version of emsdk, so there is no
|
|
|
|
need to build it yourself prior.
|
2018-02-23 19:34:33 +00:00
|
|
|
|
2018-06-19 14:56:17 +00:00
|
|
|
Additional build prerequisites are:
|
|
|
|
|
2018-06-21 15:19:34 +00:00
|
|
|
- A working native compiler toolchain, enough to build CPython.
|
2018-07-18 13:26:18 +00:00
|
|
|
- A native Python 3.7 to run the build scripts.
|
2018-06-21 15:19:34 +00:00
|
|
|
- PyYAML
|
2018-06-19 14:56:17 +00:00
|
|
|
- [lessc](https://lesscss.org/) to compile less to css.
|
|
|
|
- [uglifyjs](https://github.com/mishoo/UglifyJS) to minify Javascript builds.
|
2018-07-24 13:10:05 +00:00
|
|
|
- [ccache](https://ccache.samba.org) (optional) recommended for much faster rebuilds.
|
2018-04-26 15:04:28 +00:00
|
|
|
|
2018-07-24 15:18:01 +00:00
|
|
|
|
2018-06-21 15:19:34 +00:00
|
|
|
`make`
|
2018-03-30 14:51:13 +00:00
|
|
|
|
2018-10-08 19:33:33 +00:00
|
|
|
## 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. cd `/src`
|
|
|
|
|
|
|
|
4. Run `make` to build.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
2018-03-30 14:51:13 +00:00
|
|
|
# Testing
|
|
|
|
|
2018-06-21 15:19:34 +00:00
|
|
|
Install the following dependencies into the default Python installation:
|
2018-03-30 14:51:13 +00:00
|
|
|
|
2018-07-19 15:16:10 +00:00
|
|
|
`pip install pytest selenium pytest-instafail`
|
2018-03-30 14:51:13 +00:00
|
|
|
|
2018-07-26 09:45:00 +00:00
|
|
|
Install [geckodriver](https://github.com/mozilla/geckodriver/releases) and
|
|
|
|
[chromedriver](https://sites.google.com/a/chromium.org/chromedriver/downloads) somewhere
|
2018-06-21 15:19:34 +00:00
|
|
|
on your `PATH`.
|
2018-03-30 14:51:13 +00:00
|
|
|
|
2018-08-28 09:59:12 +00:00
|
|
|
`pytest test/`
|
2018-04-11 14:17:02 +00:00
|
|
|
|
|
|
|
# Benchmarking
|
|
|
|
|
2018-06-21 15:19:34 +00:00
|
|
|
Install the same dependencies as for testing.
|
2018-04-11 14:17:02 +00:00
|
|
|
|
2018-06-21 15:19:34 +00:00
|
|
|
`make benchmark`
|
2018-06-14 18:19:08 +00:00
|
|
|
|
|
|
|
# Linting
|
|
|
|
|
2018-06-21 15:19:34 +00:00
|
|
|
Python is linted with `flake8`. C and Javascript are linted with `clang-format`.
|
2018-06-14 18:19:08 +00:00
|
|
|
|
2018-06-21 15:19:34 +00:00
|
|
|
`make lint`
|