-
Notifications
You must be signed in to change notification settings - Fork 6
/
install-and-set-up-conda.sh
98 lines (77 loc) · 3.66 KB
/
install-and-set-up-conda.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#! /bin/bash
set -e
# - Installs mambaforge to ${HOME}/mambaforge. Version is determined by common.sh,
# which is downloaded at runtime.
# - Sets channel order and sets strict channel priority
# - Installs bioconda-utils into a "bioconda" env (unless
# $BIOCONDA_DISABLE_BUILD_PREP=1). Version is determined by common.sh.
# - Sets up local channel to have highest priority (unless $BIOCONDA_DISABLE_BUILD_PREP=1)
for dep in configure-conda.sh common.sh
do
if [ ! -f $dep ]
then
echo "ERROR: The file $dep cannot be found in $(pwd). Please ensure it is present, e.g. using wget from the bioconda/bioconda-common repository. Exiting."
exit 1
fi
done
# Extract the versions we should be using from common.sh
source common.sh
# assert that common.sh has set the variables we need
for var in BIOCONDA_UTILS_TAG MAMBAFORGE_VER MAMBAFORGE_INSTALLATION_DIR
do
if [ -z ${var+x} ]
then
echo "ERROR: The variable $var is not set by common.sh. Exiting."
exit 1
fi
done
BIOCONDA_UTILS_VER=$(echo ${BIOCONDA_UTILS_TAG} | sed "s/^v//g")
ARCH=$(uname -m)
if [[ $(uname) == "Darwin" ]]; then
OS="MacOSX"
# Remove existing installation on macOS runners
sudo rm -rf ${MAMBAFORGE_INSTALLATION_DIR}
sudo mkdir -p $(dirname $MAMBAFORGE_INSTALLATION_DIR)
sudo chown -R $USER $(dirname $MAMBAFORGE_INSTALLATION_DIR)
# conda-forge-ci-setup does some additional setup for Mac.
BIOCONDA_ADDITIONAL_INSTALL_PKGS="conda-forge-ci-setup"
else
mkdir -p $(dirname $MAMBAFORGE_INSTALLATION_DIR)
OS="Linux"
BIOCONDA_ADDITIONAL_INSTALL_PKGS=""
fi
MINIFORGE_URL="https://github.com/conda-forge/miniforge/releases/download/${MAMBAFORGE_VER}/Miniforge3-${MAMBAFORGE_VER}-${OS}-${ARCH}.sh"
# Install mambaforge
echo Download ${MINIFORGE_URL}
curl -L ${MINIFORGE_URL} > mambaforge.sh
head mambaforge.sh
bash mambaforge.sh -b -p "${MAMBAFORGE_INSTALLATION_DIR}"
export PATH="${MAMBAFORGE_INSTALLATION_DIR}/bin:${PATH}"
# Set up channels
# disable build preparation here because we don't yet have the local channel from conda-build
BIOCONDA_DISABLE_BUILD_PREP=1 bash configure-conda.sh
# By default, for building packages, we install bioconda-utils. However when
# testing bioconda-utils itself, we don't want to install a release, in
# which case set BIOCONDA_DISABLE_BUILD_PREP to a non-zero value.
if [ ${BIOCONDA_DISABLE_BUILD_PREP:=0} == 0 ]; then
source ${MAMBAFORGE_INSTALLATION_DIR}/etc/profile.d/conda.sh
source ${MAMBAFORGE_INSTALLATION_DIR}/etc/profile.d/mamba.sh
# set up env with all dependencies
conda create -n bioconda -y --file https://raw.githubusercontent.com/bioconda/bioconda-utils/$BIOCONDA_UTILS_TAG/bioconda_utils/bioconda_utils-requirements.txt $BIOCONDA_ADDITIONAL_INSTALL_PKGS
conda activate bioconda
# install bioconda-utils itself via pip (this way we don't always have to wait for the conda package to be built before being able to fix things here)
pip install git+https://github.com/bioconda/bioconda-utils.git@$BIOCONDA_UTILS_TAG
# Set local channel as highest priority (requires conda-build, which is
# installed as a dependency of bioconda-utils)
mkdir -p "${MAMBAFORGE_INSTALLATION_DIR}/conda-bld/{noarch,linux-64,osx-64,linux-aarch64,osx-arm64}"
# The base installation does not include conda-index, so use "command conda" to run bioconda
# env's "conda index".
command conda index "${MAMBAFORGE_INSTALLATION_DIR}/conda-bld"
conda config --add channels "file://${MAMBAFORGE_INSTALLATION_DIR}/conda-bld"
fi
echo "=========="
echo "conda config:"
conda config --show
echo "=========="
echo "environment(s): $(conda env list)"
echo "DONE setting up via $0"