Add devcontainer configurations (#4402)

Adds two devcontainer configurations:

* configuration "Docker": the default, equivalent to using run_docker 
* configuration "Conda"

Codespaces and VS Code allow users to select the configuration.
This commit is contained in:
Matthias Köppe 2024-01-22 16:32:09 -08:00 committed by GitHub
parent fde32e9d8b
commit a505bd5215
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 85 additions and 2 deletions

View File

@ -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"
}
}
}

View File

@ -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"
}

31
.devcontainer/onCreate-conda.sh Executable file
View File

@ -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

View File

@ -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

View File

@ -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