diff --git a/README.md b/README.md index f55bee32055c9c31bb207f1c5c1eb268377841c9..933d509b5596e048fadd6c85951fe5e77666927c 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ system. Use it and update it if you must. ## Basic conda installation -If you still don't have a basic conda installation, use `bootstrap-conda.sh` to -bootstrap a new installation: +If you still don't have a basic conda installation, use `install-conda.sh` to +create a new installation: ```sh -$ ./bootstrap-conda.sh /opt/conda +$ ./install-conda.sh /opt/conda ``` The single parameter defines the prefix of the installation. You'll use this @@ -38,7 +38,7 @@ The parameters are: Once the environment is generated, you may generate the package list like this: ```sh -$ /opt/conda/bin/conda list -n bob-devel-py27 -e > devel-py27.txt +$ /opt/conda/bin/conda list -n bob-devel-py27 -e > linux/devel-py27.txt ``` diff --git a/bootstrap-conda.sh b/bootstrap-conda.sh index 80d6fb064fd47ad9f44ac1ba49aeb8c2e0143dbe..b8ec88ec227b31531556bc98a690356a9dd7c5d9 100755 --- a/bootstrap-conda.sh +++ b/bootstrap-conda.sh @@ -1,36 +1,92 @@ #!/usr/bin/env bash -# Wed 17 Aug 2016 13:50:09 CEST +# Mon 8 Aug 17:40:24 2016 CEST -if [ "${#}" != 1 ]; then - echo "usage: `basename $0` <prefix>" - echo "example: `basename $0` /opt/conda" +# Creates a build environment for the current package +# $1 == conda folder (e.g. "/opt/conda") +# $2 == python version (e.g. "2.7") +# $3 == local dir for environment (e.g. "env") + +if [ "${#}" -ne 3 ]; then + echo "usage: ${0} <conda-root> <python-version> <prefix>" + echo "example: ${0} /opt/conda 2.7 env" exit 1 fi -BASEDIR=$1 -CONDA=${BASEDIR}/bin/conda -MINICONDA=${HOME}/Downloads/miniconda.sh +CONDA_FOLDER=${1} +PYTHON_VERSION=${2} +PREFIX=`pwd`/${3} +WHEELS_SERVER="www.idiap.ch" +WHEELS_REPOSITORY="https://${WHEELS_SERVER}/software/bob/wheels/gitlab/" +# Determines the architecture we're using if [ "$(uname)" == "Darwin" ]; then - ARCH="MacOSX-x86_64" + ARCH="macosx" +else + ARCH="linux" +fi + +# Function for running command and echoing results +run_cmd() { + echo "[(`date +%c`)>>] Running \"${@}\"..." + ${@} + if [ "$?" != "0" ]; then + echo "[(`date +%c`)!!] Command Failed \"${@}\"" + exit 1 + else + echo "[(`date +%c`)<<] Finished comand \"${@}\"" + fi +} + +# Clones the conda dev environment to use +if [ ! -d ${PREFIX} ]; then + echo "[++] Bootstrapping (clone) conda installation at ${PREFIX}..." + pyver=$(echo ${PYTHON_VERSION} | tr -d '.') + run_cmd curl --silent https://gitlab.idiap.ch/bob/bob.admin/raw/master/${ARCH}/devel-py${pyver}.txt > env.txt + run_cmd ${CONDA_FOLDER}/bin/conda create --prefix ${PREFIX} --file env.txt --yes + run_cmd ${CONDA_FOLDER}/bin/conda clean --lock +else + echo "[!!] Prefix directory ${PREFIX} exists, not re-installing..." +fi + +# Source the newly created conda environment +echo "[>>] Running \"source ${CONDA_FOLDER}/bin/activate ${PREFIX}\"..." +source ${CONDA_FOLDER}/bin/activate ${PREFIX} +echo "[<<] Environment ${PREFIX} activated" + +# Verify where pip is installed +use_pip=`which pip` +if [ -z "${use_pip}" ]; then + echo "[!!] Cannot find pip, aborting..." + exit 1 else - ARCH="Linux-x86_64" + echo "[++] Using pip: ${use_pip}" fi -if [ ! -x ${MINICONDA} ]; then - mkdir -pv `dirname ${MINICONDA}` - echo "[>>] Downloading `basename ${MINICONDA}` -> ${MINICONDA}..." - curl --progress-bar https://repo.continuum.io/miniconda/Miniconda3-latest-${ARCH}.sh --output ${MINICONDA} - chmod 755 ${MINICONDA} +use_python=`which python` +if [ -z "${use_python}" ]; then + echo "[!!] Cannot find python, aborting..." + exit 1 +else + echo "[++] Using python: ${use_python}" fi -# Create root environment and add basic channels for conda -if [ ! -x ${CONDA} ]; then - echo "[>>] Creating root environment and setting basic options..." - bash ${MINICONDA} -b -p ${BASEDIR} - ${CONDA} config --set show_channel_urls True - ${CONDA} config --add channels conda-forge +# Install this package's build dependencies +if [ -e requirements.txt ]; then + run_cmd ${use_pip} install --find-links ${WHEELS_REPOSITORY} --use-wheel --no-index --trusted-host ${WHEELS_SERVER} --pre --requirement requirements.txt +else + echo "[!!] No requirements.txt file found, skipping 'pip install <build-deps>'..." fi -echo "[>>] Updating conda in the root environment..." -${CONDA} update --yes -n root conda +# Install this package's test dependencies +if [ -e test-requirements.txt ]; then + run_cmd ${use_pip} install --find-links ${WHEELS_REPOSITORY} --use-wheel --no-index --trusted-host ${WHEELS_SERVER} --pre --requirement test-requirements.txt +else + echo "[!!] No test-requirements.txt file found, skipping 'pip install <test-deps>'..." +fi + +# Finally, bootstrap the installation from the new environment +if [ -e bootstrap-buildout.py ]; then + run_cmd ${use_python} bootstrap-buildout.py +else + echo "[!!] No bootstrap-buildout.py file found, skipping 'buildout bootstrap'..." +fi diff --git a/install-conda.sh b/install-conda.sh new file mode 100755 index 0000000000000000000000000000000000000000..80d6fb064fd47ad9f44ac1ba49aeb8c2e0143dbe --- /dev/null +++ b/install-conda.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# Wed 17 Aug 2016 13:50:09 CEST + +if [ "${#}" != 1 ]; then + echo "usage: `basename $0` <prefix>" + echo "example: `basename $0` /opt/conda" + exit 1 +fi + +BASEDIR=$1 +CONDA=${BASEDIR}/bin/conda +MINICONDA=${HOME}/Downloads/miniconda.sh + +if [ "$(uname)" == "Darwin" ]; then + ARCH="MacOSX-x86_64" +else + ARCH="Linux-x86_64" +fi + +if [ ! -x ${MINICONDA} ]; then + mkdir -pv `dirname ${MINICONDA}` + echo "[>>] Downloading `basename ${MINICONDA}` -> ${MINICONDA}..." + curl --progress-bar https://repo.continuum.io/miniconda/Miniconda3-latest-${ARCH}.sh --output ${MINICONDA} + chmod 755 ${MINICONDA} +fi + +# Create root environment and add basic channels for conda +if [ ! -x ${CONDA} ]; then + echo "[>>] Creating root environment and setting basic options..." + bash ${MINICONDA} -b -p ${BASEDIR} + ${CONDA} config --set show_channel_urls True + ${CONDA} config --add channels conda-forge +fi + +echo "[>>] Updating conda in the root environment..." +${CONDA} update --yes -n root conda