This document shows how to build Pyodide
Create A Virtual Machine through SlapOS to compile Pyodide
In SlapOS (How To create an account) click on Services, then Add
From the list select KVM for Kernel-based Virtual Machine. Select the KVM Version. This document uses KVM version 1.0.67.
Set your own title, and set the parameters to 4GB RAM, 30GB Hard Disk Space and 1 External Disk. Computer Field is left empty. Click Proceed.
Let SlapOS set up the machine, after a while the links in 'Connection Parameters' at the bottom will populate. Wait until 'url' field is ready then click it.
Install Debian on VM
After going to the url in Connection Parameters, you will be greeted with noVNC Screen. Press Connect. You should see the starting screen for installing debian. This version is going to install Debian 9.
Below is the list of settings used in this document. You may choose the ones which best fit you.
- Install Debian
- English Language
- France Location
- United States Local
- French Keyboard
- Hostname: debian
- Domain Name: debian1
- Set Root password
- Set Username and password
- All files in one partition
- Yes; format disk
- France package manager
- Blank proxy information
- Install os on hard disk, in dev/vda
Install Sudo and add your user to it
Open the Terminal and type the following commands:
apt-get install sudo
sudo adduser <username> sudo
Restart computer, log in again.
(Optional) Set Up Machine for SSH
Check if the machine has ssh_host keys needed to be ssh'ed into. In the terminal run
If the folder does not have _key and .pub files, you need to install openssh to be able to ssh into the machine. In the terminal run
sudo apt-get install openssh-server
Check /etc/hosts again to find an RSA key. Now you can ssh into the machine.
For ssh you need the username, hostname and port. Username is the username of the account created in the virtual machine (in this case 'rs'). Host address can be found in
Slapos > Services > Your KVM Machine Service > Connection Parameters Table > nat-rule-port-22:
In this case the hostname is '2001:67c:1254:e:c4::eb88' with port 10022. In terminal on your machine type
ssh [username]@[hostname] -p 10022
Then, enter the password for the username account.
Download Prerequisites for Pyodide
Pyodide has prerequisites need to be able to build Pyodide locally. List of Prerequisites can be found in the Github Pyodide Repo
Create a new folder to contain all the files we will need to download.
In the terminal:
Install emsdk Prerequisites
Pyodide will compile its own version of emsdk. emsdk Prerequisites for Linux are in its documentation page. All of them will be installed below.
First download emsdk itself.
sudo apt-get install git
git clone https://github.com/juj/emsdk.git
Install python3.7.0 on debian 9
Pyodide needs python 3.7.0 or newer. Instructions taken from StackExchange Post
Install these packages beforehand:
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev
sudo apt-get install -y libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm
sudo apt-get install -y libncurses5-dev libncursesw5-dev xz-utils tk-dev
Then download Python source code and compile it.
tar xvf Python-3.7.0.tgz
sudo make altinstall
Update path of python3 and python to point to the newly installed python.
sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.7 50
sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.7 50
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 40
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 30
Install newest Nodejs and npm
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
If you get
ImportError: No module named 'lsb_release.py' while trying to install nodejs then update the location of lsb_release.py and run
sudo ln -s /usr/share/pyshared/lsb_release.py /usr/local/lib/python3.6/site-packages/lsb_release.py
curl completes, install nodejs:
sudo apt-get install -y nodejs
Install the libYAML and it's headers
sudo apt-get install libyaml-dev
Download the pyyaml sources:
Install from sources:
tar xzf PyYAML-3.13.tar.gz
sudo python3 setup.py install
sudo python3 setup.py test
sudo apt-get install -y cmake
sudo apt-get install -y ccache
sudo npm install -g uglify-js
sudo npm install -g less
Clone the files from Pyodide github repo, go into the newly created directory with downloaded files and run make.
git clone https://github.com/iodide-project/pyodide.git
Building updated Pyodide
Tip from @rth, building Pyodide the first time takes a long time, as LLVM has to build. Next time, you can shorten the build time by running:
make -C cpython clean
Instead of just
make. It deletes cpython and builds Pyodide again, without having to rebuild LLVM and emsdk. Shortens build time to under 2 hours from 8 hours.