-
André Anjos authoredAndré Anjos authored
before_build.sh 2.60 KiB
#!/usr/bin/env bash
# Mon 8 Aug 17:40:24 2016 CEST
source $(dirname ${0})/functions.sh
check_env DOCSERVER
check_env CONDA_FOLDER
check_env PYTHON_VER
check_env CONDA_PREFIX
check_env ARCH
check_env PREFIX
check_env CI_PROJECT_NAME
WHEELS_REPOSITORY="${DOCSERVER}/software/bob/wheels/gitlab/"
WHEELS_SERVER=`echo ${DOCSERVER} | sed 's;https\?://;;'`
# Clones the conda dev environment to use
if [ ! -d ${PREFIX} ]; then
log_info "Downloading environment list into file \`env.txt'..."
pyver=$(echo ${PYTHON_VER} | tr -d '.')
run_cmd curl --silent --output env.txt https://gitlab.idiap.ch/bob/bob.admin/raw/master/install/${ARCH}/devel-py${pyver}.txt
log_info "Bootstrapping conda installation at ${PREFIX}..."
run_cmd ${CONDA_FOLDER}/bin/conda clean --lock
run_cmd ${CONDA_FOLDER}/bin/conda create --prefix ${PREFIX} --file env.txt --yes
# Dirty fix to libjpeg.8 compilation issues:
# https://github.com/ContinuumIO/anaconda-issues/issues/1042
if [ "${ARCH}" == "macosx" ] && [ -e "${PREFIX}/lib/libjpeg.8.dylib" ]; then
run_cmd install_name_tool -id @rpath/libjpeg.8.dylib ${PREFIX}/lib/libjpeg.8.dylib
fi
run_cmd ${CONDA_FOLDER}/bin/conda clean --lock
else
log_warn "Prefix directory ${PREFIX} exists, not re-installing..."
fi
# Source the newly created conda environment
log_info "Running \"source ${CONDA_FOLDER}/bin/activate ${PREFIX}\"..."
source ${CONDA_FOLDER}/bin/activate ${PREFIX}
log_info "Environment ${PREFIX} activated"
# Verify where pip is installed
use_pip=`which pip`
if [ -z "${use_pip}" ]; then
log_error "Cannot find pip, aborting..."
exit 1
else
log_info "Using pip: ${use_pip}"
fi
use_python=`which python`
if [ -z "${use_python}" ]; then
log_error "Cannot find python, aborting..."
exit 1
else
log_info "Using python: ${use_python}"
fi
# Install this package's build dependencies
PIPOPTS="--find-links ${WHEELS_REPOSITORY} --trusted-host ${WHEELS_SERVER}"
PIPOPTS="${PIPOPTS} --pre --use-wheel --no-index"
if [ -e requirements.txt ]; then
run_cmd ${use_pip} install ${PIPOPTS} --requirement requirements.txt
else
log_info "No requirements.txt file found, skipping 'pip install <build-deps>'..."
fi
# Install this package's test dependencies
if [ -e test-requirements.txt ]; then
run_cmd ${use_pip} install ${PIPOPTS} --requirement test-requirements.txt
else
log_info "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
log_error "No bootstrap-buildout.py file found, stopping..."
exit 1
fi