2020-10-30 20:09:25 +00:00
(building_from_sources)=
2020-05-08 23:28:44 +00:00
# Building from sources
2020-05-19 16:14:56 +00:00
Building is easiest on Linux and relatively straightforward on Mac. For
Windows, we currently recommend using the Docker image (described below) to
build Pyodide.
2020-05-08 23:28:44 +00:00
2020-05-20 16:58:43 +00:00
## Build using `make`
2020-05-19 16:14:56 +00:00
Make sure the prerequisites for [emsdk ](https://github.com/emscripten-core/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:
2020-07-22 18:36:45 +00:00
- A working native compiler toolchain, enough to build [CPython ](https://devguide.python.org/setup/#linux ).
2020-07-07 14:21:33 +00:00
- A native Python 3.8 to run the build scripts.
2020-07-22 18:36:45 +00:00
- CMake
2020-05-19 16:14:56 +00:00
- PyYAML
2020-07-22 18:36:45 +00:00
- FreeType 2 development libraries to compile Matplotlib.
2020-05-19 16:14:56 +00:00
- [lessc ](http://lesscss.org/ ) to compile less to css.
- [uglifyjs ](https://github.com/mishoo/UglifyJS ) to minify Javascript builds.
- gfortran (GNU Fortran 95 compiler)
- [f2c ](http://www.netlib.org/f2c/ )
- [ccache ](https://ccache.samba.org ) (optional) *highly* recommended for much faster rebuilds.
On Mac, you will also need:
- [Homebrew ](https://brew.sh/ ) 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`)
After installing the build prerequisites, run from the command line:
```bash
make
```
2020-05-20 16:58:43 +00:00
## Using Docker
2020-05-19 16:14:56 +00:00
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
2020-06-28 13:51:46 +00:00
be changed via Docker Preferences (See [here ](https://stackoverflow.com/questions/44533319/how-to-assign-more-memory-to-docker-container )).
2020-05-19 16:14:56 +00:00
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.
2020-05-08 23:28:44 +00:00
2020-10-30 20:09:25 +00:00
(partial-builds)=
2020-05-08 23:28:44 +00:00
## Partial builds
2020-05-08 23:46:59 +00:00
To build a subset of available packages in pyodide, set the environment
2020-05-08 23:28:44 +00:00
variable `PYODIDE_PACKAGES` to a comma separated list of packages. For
instance,
```
PYODIDE_PACKAGES="toolz,attrs" make
```
2020-05-09 10:22:09 +00:00
Note that this environment variable must contain both the packages and their
2020-05-09 00:07:39 +00:00
dependencies. The package names must match the folder names in `packages/`
2020-05-08 23:28:44 +00:00
exactly; in particular they are case sensitive.
2020-05-08 23:46:59 +00:00
To build a minimal version of pyodide, set `PYODIDE_PACKAGES="micropip"` . The
2020-05-09 10:22:09 +00:00
micropip and package is generally always included for any non empty value of
2020-05-08 23:46:59 +00:00
`PYODIDE_PACKAGES` .
2020-05-09 10:39:05 +00:00
If scipy is included in `PYODIDE_PACKAGES` , BLAS/LAPACK must be manually built
2020-07-08 14:58:10 +00:00
first with `make -c packages/CLAPACK` .
2020-06-28 13:51:46 +00:00
2020-07-13 19:46:20 +00:00
## Environment variables
2020-06-28 13:51:46 +00:00
Following environment variables additionally impact the build,
- `PYODIDE_JOBS` : the `-j` option passed to the `emmake make` command when applicable for parallel compilation. Default: 3.