From e72d963b5759e0b8d0a90ea30d0c0a57889fdb7a Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Sat, 29 Jul 2017 18:19:41 -0700 Subject: [PATCH] Fix conda builder + add tests --- MANIFEST.in | 3 +- repo2docker/detectors.py | 5 ++- repo2docker/files/conda/environment.yml | 9 +++++ .../files/conda/install-miniconda.bash | 39 +++++++++++++++++++ tests/conda/simple/environment.yml | 2 + tests/conda/simple/verify | 6 +++ 6 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 repo2docker/files/conda/environment.yml create mode 100755 repo2docker/files/conda/install-miniconda.bash create mode 100644 tests/conda/simple/environment.yml create mode 100755 tests/conda/simple/verify diff --git a/MANIFEST.in b/MANIFEST.in index 9019d87f..930416fe 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ include *.md include LICENSE -include setup.cfg \ No newline at end of file +include setup.cfg +include repo2docker/files/* diff --git a/repo2docker/detectors.py b/repo2docker/detectors.py index 29ed5394..1c49bd98 100644 --- a/repo2docker/detectors.py +++ b/repo2docker/detectors.py @@ -152,6 +152,7 @@ class BuildPack(LoggingConfigurable): "curl", "wget", "less", + "ca-certificates", # Include everything from the popular buildpack-deps docker image "autoconf", "automake", @@ -550,8 +551,8 @@ class CondaBuildPack(BuildPack): path = ['${CONDA_DIR}/bin'] build_script_files = { - 'conda/install-miniconda.bash': '/tmp/install-miniconda.bash', - 'conda/environment.yml': '/tmp/environment.yml' + os.path.join(os.path.dirname(__file__), 'files', 'conda', 'install-miniconda.bash'): '/tmp/install-miniconda.bash', + os.path.join(os.path.dirname(__file__), 'files', 'conda', 'environment.yml'): '/tmp/environment.yml', } build_scripts = [ diff --git a/repo2docker/files/conda/environment.yml b/repo2docker/files/conda/environment.yml new file mode 100644 index 00000000..9e036232 --- /dev/null +++ b/repo2docker/files/conda/environment.yml @@ -0,0 +1,9 @@ +dependencies: + - python==3.6.1 + - notebook==5.0.0 + - ipython==6.0.0 + - ipykernel==4.6.0 + - ipywidgets==6.0.0 + - jupyterlab==0.22.1 + - pip: + - jupyterhub==0.7.2 diff --git a/repo2docker/files/conda/install-miniconda.bash b/repo2docker/files/conda/install-miniconda.bash new file mode 100755 index 00000000..5078fc2d --- /dev/null +++ b/repo2docker/files/conda/install-miniconda.bash @@ -0,0 +1,39 @@ +#!/bin/bash +# This downloads and installs a pinned version of miniconda +set -ex + +cd $(dirname $0) +CONDA_VERSION=4.3.14 +URL="https://repo.continuum.io/miniconda/Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh" +INSTALLER_PATH=/tmp/miniconda-installer.sh + +wget --quiet $URL -O ${INSTALLER_PATH} +chmod +x ${INSTALLER_PATH} + +# Only MD5 checksums are available for miniconda +# Can be obtained from https://repo.continuum.io/miniconda/ +MD5SUM="fc6fc37479e3e3fcf3f9ba52cae98991" + +if ! echo "${MD5SUM} ${INSTALLER_PATH}" | md5sum --quiet -c -; then + echo "md5sum mismatch for ${INSTALLER_PATH}, exiting!" + exit 1 +fi + +bash ${INSTALLER_PATH} -b -p ${CONDA_DIR} + +# Allow easy direct installs from conda forge +${CONDA_DIR}/bin/conda config --system --add channels conda-forge + +# Do not attempt to auto update conda or dependencies +${CONDA_DIR}/bin/conda config --system --set auto_update_conda false +${CONDA_DIR}/bin/conda config --system --set update_dependencies false +${CONDA_DIR}/bin/conda config --system --set show_channel_urls true + +${CONDA_DIR}/bin/conda env update -n root -f /tmp/environment.yml +# Clean things out! +${CONDA_DIR}/bin/conda clean -tipsy + +# Remove the big installer so we don't increase docker image size too much +rm ${INSTALLER_PATH} + +chown -R $NB_USER:$NB_USER ${CONDA_DIR} diff --git a/tests/conda/simple/environment.yml b/tests/conda/simple/environment.yml new file mode 100644 index 00000000..6a91d667 --- /dev/null +++ b/tests/conda/simple/environment.yml @@ -0,0 +1,2 @@ +dependencies: + - numpy diff --git a/tests/conda/simple/verify b/tests/conda/simple/verify new file mode 100755 index 00000000..4ad54bfd --- /dev/null +++ b/tests/conda/simple/verify @@ -0,0 +1,6 @@ +#!/usr/bin/env python +import sys + +assert sys.version_info[:2] == (3, 6) + +import numpy