Skip to content

Contributing to Basthon ​

Prerequisites ​

  • Node.js ≥ 22.12 (the *.mts build scripts run with type stripping, the tests with Vitest) and Yarn, in the version set by packageManager in package.json (corepack enable is enough);
  • Python 3 with the venv module;
  • for the OCaml kernel: dune, js_of_ocaml, the OCaml libraries offered by #require and a C compiler (on Debian, the packages listed in docker/000.build.dockerfile);
  • for the tests in browsers: Firefox, Chrome and Edge by default (BASTHON_TESTS_BROWSERS chooses them), found or downloaded by Selenium Manager with their drivers. To run only the tests in Node.js, set BASTHON_TESTS_BACKENDS=node (see tests/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:

bash
corepack enable
yarn install
python3 -m venv .venv
.venv/bin/pip install -r requirements-dev.txt

The 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…CommandPython tools used
build the projectyarn buildbuild (requirements/build.txt)
change Python codeblack . before committingblack (requirements/lint.txt)
build the website and its docyarn wwwgriffe (requirements/doc.txt)
run the testsyarn testnone: 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.