Contributing to Basthon
Prerequisites
- Node.js ≥ 22.12 (the
*.mtsbuild scripts run with type stripping, the tests with Vitest) and Yarn, in the version set bypackageManagerinpackage.json(corepack enableis enough); - Python 3 with the
venvmodule; - for the OCaml kernel: dune, js_of_ocaml, the OCaml libraries offered by
#requireand a C compiler (on Debian, the packages listed indocker/000.build.dockerfile); - for the tests in browsers: Firefox, Chrome and Edge by default (
BASTHON_TESTS_BROWSERSchooses them), found or downloaded by Selenium Manager with their drivers. To run only the tests in Node.js, setBASTHON_TESTS_BACKENDS=node(seetests/lib/env.ts).
The build Docker image has all the build tools: yarn docker run build opens a shell in it, in the repository.
Installation
Install the JavaScript dependencies (all the packages are Yarn workspaces), then the Python tools, listed with pinned versions in requirements-dev.txt, in a virtual environment at the root of the repository:
corepack enable
yarn install
python3 -m venv .venv
.venv/bin/pip install -r requirements-dev.txtThe website (www/) is its own Yarn project: yarn www installs its dependencies.
Then activate this environment (source .venv/bin/activate) before running the commands below: the scripts call python3 -m build and python3 (griffe) from the PATH.
| If you… | Command | Python tools used |
|---|---|---|
| build the project | yarn build | build (requirements/build.txt) |
| change Python code | black . before committing | black (requirements/lint.txt) |
| build the website and its doc | yarn www | griffe (requirements/doc.txt) |
| run the tests | yarn test | none: Python runs in Pyodide |
When @basthon/xcas-wasm (Giac) is updated, regenerate the list of Giac's commands completed by the XCAS kernel (packages/kernel-xcas/src/giac-commands.ts, committed) with yarn update-commands in packages/kernel-xcas/ (about two minutes, see scripts/giac-commands.mts).
The CI checks the style with black . --check: a badly formatted Python file makes the pipeline fail. The codestyle Docker image installs black from requirements/lint.txt: to change its version, just edit this file.
How the kernel works
How the kernel works (isolated kernels in an opaque origin worker, proxy, synchronous communication, kernel iframes...) is described in Architecture and security (source: doc/technique/architecture.md). The tricky parts have their own note in doc/technique/, e.g. Pyodide snapshots. To add a language, see Writing a new kernel (source: doc/technique/new-kernel.md).
Technical documentation meant for contributors (this file, doc/technique/, code comments, the changelog) is written in English.