diff --git a/.devcontainer/conda/devcontainer.json b/.devcontainer/conda/devcontainer.json new file mode 100644 index 000000000..9969e5556 --- /dev/null +++ b/.devcontainer/conda/devcontainer.json @@ -0,0 +1,19 @@ +{ + "name": "Conda", + "image": "mcr.microsoft.com/devcontainers/base:bullseye", + + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode", + + // Setup conda environment + "onCreateCommand": ".devcontainer/onCreate-conda.sh", + + // Install additional features. + "features": { + // For config options, see https://github.com/devcontainers/features/tree/main/src/conda + "ghcr.io/devcontainers/features/conda": { + "version": "latest", + "addCondaForge": "true" + } + } +} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..8df4d9fe8 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,7 @@ +{ + "name": "Docker", + // keep in sync with "run_docker" + "image": "pyodide/pyodide-env:20230506-chrome112-firefox112-py311", + "remoteUser": "root", + "onCreateCommand": ".devcontainer/onCreate-docker.sh" +} diff --git a/.devcontainer/onCreate-conda.sh b/.devcontainer/onCreate-conda.sh new file mode 100755 index 000000000..4856568ce --- /dev/null +++ b/.devcontainer/onCreate-conda.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# Do not keep running on errors +set -ex + +# from https://pyodide.org/en/stable/development/building-from-sources.html#using-make: +# - build-essential +# we install pkg-config with apt because it is commented out in environment.yml +sudo apt-get update && sudo apt-get install --yes build-essential pkg-config + +conda env create -n pyodide-env -f environment.yml +conda init bash +echo "conda activate pyodide-env" >> ~/.bashrc + +# conda run -n pyodide-env make -C emsdk clean +# conda run -n pyodide-env make -C cpython clean + +# https://pyodide.org/en/stable/development/building-from-sources.html#using-docker +export EMSDK_NUM_CORE=12 EMCC_CORES=12 PYODIDE_JOBS=12 +echo "export EMSDK_NUM_CORE=12 EMCC_CORES=12 PYODIDE_JOBS=12" >> ~/.bashrc +echo "export PYODIDE_BUILD_TMP=/tmp/pyodide-build" >> ~/.bashrc + +conda run -n pyodide-env --live-stream pip install -r requirements.txt + +# https://pyodide.org/en/stable/development/new-packages.html#prerequisites +conda run -n pyodide-env --live-stream pip install -e ./pyodide-build + +# Building emsdk and cpython takes a few minutes to run, so we do not run it here. +# +# conda run -n pyodide-env --live-stream make -C emsdk +# conda run -n pyodide-env --live-stream make -C cpython diff --git a/.devcontainer/onCreate-docker.sh b/.devcontainer/onCreate-docker.sh new file mode 100755 index 000000000..885c2273c --- /dev/null +++ b/.devcontainer/onCreate-docker.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Do not keep running on errors +set -e + +# https://pyodide.org/en/stable/development/new-packages.html#prerequisites +pip install -e ./pyodide-build + +# Building emsdk and cpython takes a few minutes to run, so we do not run it here. +# +# make -C emsdk +# make -C cpython diff --git a/docs/development/building-from-sources.md b/docs/development/building-from-sources.md index ee2e2b626..5728e3f31 100644 --- a/docs/development/building-from-sources.md +++ b/docs/development/building-from-sources.md @@ -60,6 +60,20 @@ You can edit the files in the shared `pyodide` source folder on your host machine (outside of Docker), and then repeatedly run `make` inside the Docker environment to test your changes. +### Using the "Docker" dev container + +We provide a dev container configuration that is equivalent to the use of +`./run_docker` script. It can be used in [Visual Studio Code](https://code.visualstudio.com/docs/devcontainers/containers) and +on [GitHub Codespaces](https://docs.github.com/en/codespaces/overview). +When prompted, select "Docker". + +### Using the "Conda" dev container + +We provide another dev container configuration that corresponds to +the "Linux with conda" method described below. When [Visual Studio Code](https://code.visualstudio.com/docs/devcontainers/containers) or +[GitHub Codespaces](https://docs.github.com/en/codespaces/overview) +prompts for the dev container configuration, select "Conda". + ## Using `make` Make sure the prerequisites for @@ -185,8 +199,8 @@ The following environment variables additionally impact the build: with a trailing `/`. Default: `./` to load Pyodide packages from the same base URL path as where `pyodide.js` is located. Example: `{{PYODIDE_CDN_URL}}` -- `EXTRA_CFLAGS` : Add extra compilation flags. -- `EXTRA_LDFLAGS` : Add extra linker flags. +- `EXTRA_CFLAGS`: Add extra compilation flags. +- `EXTRA_LDFLAGS`: Add extra linker flags. Setting `EXTRA_CFLAGS="-D DEBUG_F"` provides detailed diagnostic information whenever error branches are taken inside the Pyodide core code. These error