Detect, configure, and use a conda-compatible tool. Use before tasks that need the project environment, such as importing project code, running tests, building docs, or invoking repo tooling.
Set up and run commands inside the CausalPy conda environment.
Use the CausalPy env when the command:
import causalpy or project modules)make, prek, or notebook executionFor simple inspection helpers that only read local text/JSON or use the Python standard library, any Python on PATH is acceptable.
Do the least work that will get the task done:
CausalPy env if one is already available.run -n CausalPy cannot resolve the env, check whether it exists under a different prefix and use run -p.make setup when dependencies changed, the editable install is stale, or the current checkout has not been installed into that env yet.Use whichever of mamba, micromamba, or conda is available (checked in that order):
# Check for mamba, micromamba, or conda (in preference order) on $PATH
CONDA_EXE=$(for c in mamba micromamba conda; do command -v "$c" &>/dev/null && echo "$c" && break; done)
If CONDA_EXE is empty, no conda-compatible tool was found. Propose installing micromamba to the user:
"${SHELL}" <(curl -L micro.mamba.pm/install.sh)
After installation, set CONDA_EXE=micromamba.
If no suitable existing env can be reused, create it:
$CONDA_EXE env create -f environment.yml
Run make setup after creating or updating the env. Also rerun it when using a different git worktree if that env has not been installed against the current checkout yet.
$CONDA_EXE run -n CausalPy make setup
Never use $CONDA_EXE activate, instead use $CONDA_EXE run -n CausalPy <command>.
$CONDA_EXE run -n CausalPy <command>
For example: $CONDA_EXE run -n CausalPy pytest, $CONDA_EXE run -n CausalPy prek run --all-files.
$CONDA_EXE env update --file environment.yml --prune
If $CONDA_EXE run -n CausalPy ... fails with errors such as The given prefix does not exist:
$CONDA_EXE env list
$CONDA_EXE run -p "/full/path/to/CausalPy" <command>
Keep using run -p with that full prefix for the rest of the session.
Git worktrees do not require a fresh env per agent session. Prefer reusing an existing env to save time. The main caveat is that this repo uses editable installs, so one shared env can point at whichever checkout most recently ran make setup.
If you hit issues with an outdated tool, update it:
$CONDA_EXE self-updateconda update -n base condaAs of 2026-02-13, current versions are conda 26.1.0, mamba/micromamba 2.5.0.