docker_utils

To ensure conda packages are built in the most compatible manner, we can use a docker container. This module supports using a docker container to build conda packages in the local channel which can later be uploaded to anaconda.

Note that we cannot simply bind the host’s conda-bld directory to the container’s conda-bld directory because during building/testing, symlinks are made to the conda-pkgs dir which is not necessarily bound. Nor should it be, if we want to retain isolation from the host when building.

To solve this, we mount the host’s conda-bld dir to a temporary directory in the container. Once the container successfully builds a package, the corresponding package is copied over to the temporary directory (the host’s conda-bld directory) so that the built package appears on the host.

In the end the workflow is:

  • build a custom docker container (assumed to already have conda installed) where the requirements in bioconda-utils/bioconda-utils_requirements.txt have been conda installed.

  • mount the host’s conda-bld to a read/write temporary dir in the container (configured in the RecipeBuilder)

  • in the container, add this directory as a local channel so that all previously-built packages can be used as dependencies.

  • mount the host’s recipe dir to a read-only dir in the container (configured in the RecipeBuilder)

  • build, mount, and run a custom script that conda-builds the mounted recipe and if successful copies the built package to the mounted host’s conda-bld directory.

Other notes:

  • Most communication with the host (conda-bld options; host’s UID) is via environmental variables passed to the container.

  • The build script is custom generated each run, providing lots of flexibility. Most magic happens here.

Functions

get_host_conda_bld()

Identifies the conda-bld directory on the host.

Classes

RecipeBuilder([tag, container_recipe, …])

Class to handle building a custom docker container that can be used for building conda recipes.

Exceptions

DockerBuildError

DockerCalledProcessError(returncode, cmd[, …])

Documentation

exception bioconda_utils.docker_utils.DockerBuildError[source]

Bases: Exception

exception bioconda_utils.docker_utils.DockerCalledProcessError(returncode, cmd, output=None, stderr=None)[source]

Bases: subprocess.CalledProcessError

bioconda_utils.docker_utils.get_host_conda_bld()[source]

Identifies the conda-bld directory on the host.

Assumes that conda-build is installed.