Building from sources¶
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.8 to run the build scripts.
- FreeType 2 development libraries to compile Matplotlib.
- lessc to compile less to css.
- gfortran (GNU Fortran 95 compiler)
- 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 (
After installing the build prerequisites, run from the command line:
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.
- Install Docker
- From a git checkout of Pyodide, run
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
make inside the Docker environment to test your changes.
To build a subset of available packages in pyodide, set the environment
PYODIDE_PACKAGES to a comma separated list of packages. For
Note that this environment variable must contain both the packages and their
dependencies. The package names must match the folder names in
exactly; in particular they are case sensitive.
To build a minimal version of pyodide, set
micropip and package is generally always included for any non empty value of
If scipy is included in
PYODIDE_PACKAGES, BLAS/LAPACK must be manually built
make -c packages/CLAPACK.
Following environment variables additionally impact the build,
-joption passed to the
emmake makecommand when applicable for parallel compilation. Default: 3.