Contents

Conda

Conda: package, dependency and environment management for scientific Python and more.

Also see Conda official docs.

Install conda on Windows

Download and install the Anaconda distribution for a quick setup.

Install conda on Linux

I made a custom script to

  • Install miniforge with
  • Use strict repository ordering.
  • Enable multithreading for faster package resolution in conda.
  • Integration with bash and zsh shells if available.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
CONDA_PATH="${HOME}/conda"
CONDA_SH="${CONDA_PATH}/etc/profile.d/conda.sh"
CONDA_URL="https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh"

# Download and install miniconda
wget -O /tmp/conda.sh "${CONDA_URL}"
bash /tmp/conda.sh -bup "${CONDA_PATH}"

source "${CONDA_SH}"
conda activate base

# conda package manager setup
# conda config --add channels conda-forge
# conda config --set channel_priority strict
conda config --set default_threads "$(nproc)"
conda config --set auto_activate_base false
mamba update -n base conda --yes
mamba update --all --yes

# `bash` and `zsh` integration
[[ -f ~/.bashrc ]] && conda init bash
[[ -f ~/.zshrc ]] && conda init zsh

Use conda in GitHub Actions

Only the crucia part is shown below. See docs for GH actions for more details.

The workflow file .github/workflows/setup-conda.yml uses setup miniconda GH action as well as the mamba package manager.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
- name: Setup conda
  uses: conda-incubator/setup-miniconda@v2
  with:
    installer-url: https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh
    channel-priority: true
    use-only-tar-bz2: true
    activate-environment: my-env

- name: Install Dependencies
  run: mamba env update -f env.yml
``