Conda

Overview

Conda is a package manager allowing you to easily and safely fetch dependencies.

Note

Conda allows you to install binary packages without requiring you to have root access. The only requirement is that you have access to the Internet.

Install Conda

You only need to create the conda environment once

$ wget -N https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh
$ bash Mambaforge-Linux-x86_64.sh -b -u -p ~/conda
$ wget -N https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-aarch64.sh
$ bash Mambaforge-Linux-aarch64.sh -b -u -p ~/conda
$ wget -N https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-MacOSX-x86_64.sh
$ bash Mambaforge-MacOSX-x86_64.sh -b -u -p ~/conda
$ wget -N https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-MacOSX-arm64.sh
$ bash Mambaforge-MacOSX-arm64.sh -b -u -p ~/conda

Note

You can always remove ~/conda and start all over again.

Activate Conda

You will need to activate the conda environment

$ source ~/conda/bin/activate

This step will override your environment variables and ensure you’re working with well known dependencies.

Note

You should activate the conda environment again, if you start a new terminal.

Create Enviroment

$ conda create --name test
$ conda activate test

Install a Package

A package from one of the default channels

$ conda install -y \
    abseil-cpp

A package from the Roq hosted conda repository

$ conda install -y \
    --channel https://roq-trading.com/conda/stable \
    roq-api

Dump Environment

$ conda list --explicit > conda.env

Recreate Environment

$ conda create --name <env> --file conda.env

Building Packages

These are the steps needed

Note

We show ALL the steps here. It is best to start with a clean conda install to avoid potential pitfalls.

$ curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
$ bash Miniforge3-$(uname)-$(uname -m).sh -b -p opt/conda
$ source opt/conda/bin/activate

Important

Do NOT create any environments. You should always run conda-build from the base environment.

$ conda install -y conda-build

Now change to the directory where you have cloned your reposity.

Note

Remember to initialize any submodules.

Then run this

$ conda build . --channel https://roq-trading.com/conda/unstable

Note

You may also choose Roq’s stable channel if you don’t want to keep up to date with current development.

You should now find your package in one of the directories under $CONDA_PREFIX/conda-bld/.

Testing Packages

Host your packages behind a web server. For example, like this:

$ cd $CONDA_PREFIX/conda-bld && python -m http.server

You can now install from another terminal like this (assuming the web server is accessible from localhost port 8000)

$ conda install --yes \
    --channel http://localhost:8000 \
    --channel https://roq-trading.com/conda/unstable \
    MY_PACKAGE_NAME