From 0d0a2f8eb9e8c20aebddccf347f14b97c5acb80e Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Wed, 4 Mar 2020 14:52:34 +0530 Subject: [PATCH] Use miniforge instead of miniconda to get conda [miniforge](https://github.com/conda-forge/miniforge) is a new community-led installer that uses conda-forge as the default channel, rather than defaults. This gives us a few advantages: - No mixing of defaults & conda-forge channel by default. My intuition is that this will reduce image size & build times, but I don't know enough about conda to say if this is real - It provides installers for architectures unsupported by miniconda. This is particularly useful important for ARM & PowerPC, when we want to support those better. - I like conda-forge, and we should do what we can to support them! This is a fairly easy, drop-in way to do so - It is more likely to have newer versions of conda by default than miniconda - It provides sha256 hashes for installers rather than just md5. This makes me personally happy There should be no user-facing changes here as far as I can tell. Fixes #858 --- repo2docker/buildpacks/conda/__init__.py | 8 ++--- ...-miniconda.bash => install-miniforge.bash} | 29 +++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) rename repo2docker/buildpacks/conda/{install-miniconda.bash => install-miniforge.bash} (74%) diff --git a/repo2docker/buildpacks/conda/__init__.py b/repo2docker/buildpacks/conda/__init__.py index e53ae08e..dc82bd4b 100644 --- a/repo2docker/buildpacks/conda/__init__.py +++ b/repo2docker/buildpacks/conda/__init__.py @@ -63,7 +63,7 @@ class CondaBuildPack(BaseImage): All scripts here should be independent of contents of the repository. - This sets up through `install-miniconda.bash` (found in this directory): + This sets up through `install-miniforge.bash` (found in this directory): - a directory for the conda environment and its ownership by the notebook user @@ -79,8 +79,8 @@ class CondaBuildPack(BaseImage): ( "root", r""" - bash /tmp/install-miniconda.bash && \ - rm /tmp/install-miniconda.bash /tmp/environment.yml + bash /tmp/install-miniforge.bash && \ + rm /tmp/install-miniforge.bash /tmp/environment.yml """, ) ] @@ -103,7 +103,7 @@ class CondaBuildPack(BaseImage): """ files = { - "conda/install-miniconda.bash": "/tmp/install-miniconda.bash", + "conda/install-miniforge.bash": "/tmp/install-miniforge.bash", "conda/activate-conda.sh": "/etc/profile.d/activate-conda.sh", } py_version = self.python_version diff --git a/repo2docker/buildpacks/conda/install-miniconda.bash b/repo2docker/buildpacks/conda/install-miniforge.bash similarity index 74% rename from repo2docker/buildpacks/conda/install-miniconda.bash rename to repo2docker/buildpacks/conda/install-miniforge.bash index 54065715..87826af9 100755 --- a/repo2docker/buildpacks/conda/install-miniconda.bash +++ b/repo2docker/buildpacks/conda/install-miniforge.bash @@ -3,14 +3,13 @@ set -ex cd $(dirname $0) -MINICONDA_VERSION=4.7.12.1 -CONDA_VERSION=4.7.12 -# Only MD5 checksums are available for miniconda -# Can be obtained from https://repo.continuum.io/miniconda/ -MD5SUM="81c773ff87af5cfac79ab862942ab6b3" +MINIFORGE_VERSION=4.8.2-1 +CONDA_VERSION=4.8.2 +# SHA256 for installers can be obtained from https://github.com/conda-forge/miniforge/releases +SHA256SUM="4f897e503bd0edfb277524ca5b6a5b14ad818b3198c2f07a36858b7d88c928db" -URL="https://repo.continuum.io/miniconda/Miniconda3-${MINICONDA_VERSION}-Linux-x86_64.sh" -INSTALLER_PATH=/tmp/miniconda-installer.sh +URL="https://github.com/conda-forge/miniforge/releases/download/4.8.2-1/Miniforge3-${MINIFORGE_VERSION}-Linux-x86_64.sh" +INSTALLER_PATH=/tmp/miniforge-installer.sh # make sure we don't do anything funky with user's $HOME # since this is run as root @@ -19,8 +18,8 @@ unset HOME wget --quiet $URL -O ${INSTALLER_PATH} chmod +x ${INSTALLER_PATH} -# check md5 checksum -if ! echo "${MD5SUM} ${INSTALLER_PATH}" | md5sum --quiet -c -; then +# check sha256 checksum +if ! echo "${SHA256SUM} ${INSTALLER_PATH}" | sha256sum --quiet -c -; then echo "md5sum mismatch for ${INSTALLER_PATH}, exiting!" exit 1 fi @@ -28,9 +27,6 @@ fi bash ${INSTALLER_PATH} -b -p ${CONDA_DIR} export PATH="${CONDA_DIR}/bin:$PATH" -# Allow easy direct installs from conda forge -conda config --system --add channels conda-forge - # Do not attempt to auto update conda or dependencies conda config --system --set auto_update_conda false conda config --system --set show_channel_urls true @@ -38,8 +34,11 @@ conda config --system --set show_channel_urls true # bug in conda 4.3.>15 prevents --set update_dependencies echo 'update_dependencies: false' >> ${CONDA_DIR}/.condarc -# install conda itself -if [[ "${CONDA_VERSION}" != "${MINICONDA_VERSION}" ]]; then +# install conda itself, if needed +# FIXME: MINIFORGE_VERSION might have a build number, like -1. +# This will force conda to be installed each time +# Use a better way of finding conda version! +if [[ "${CONDA_VERSION}" != "${MINIFORGE_VERSION}" ]]; then conda install -yq conda==${CONDA_VERSION} fi @@ -81,7 +80,7 @@ conda clean --all -f -y # Remove the big installer so we don't increase docker image size too much rm ${INSTALLER_PATH} -# Remove the pip cache created as part of installing miniconda +# Remove the pip cache created as part of installing miniforge rm -rf /root/.cache chown -R $NB_USER:$NB_USER ${CONDA_DIR}