diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml index 8b53c23a58f..db53e4c75ad 100644 --- a/.github/workflows/conda.yml +++ b/.github/workflows/conda.yml @@ -14,9 +14,11 @@ jobs: - name: Check License Lines uses: kt3k/license_checker@v1.0.3 - - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v2.0.1 + - name: Setup Mambaforge + uses: conda-incubator/setup-miniconda@v2.1.1 with: + miniforge-version: latest + miniforge-variant: Mambaforge environment-file: environment-dev.yml activate-environment: mantidimaging-dev auto-activate-base: false diff --git a/docker/Dockerfile b/docker/Dockerfile index 9d98b928338..dd78245a67f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,16 +1,16 @@ FROM mantidproject/mantidimaging:base -RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh &&\ - chmod +x Miniconda3-latest-Linux-x86_64.sh &&\ - bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/miniconda &&\ - rm Miniconda3-latest-Linux-x86_64.sh +RUN wget -nv -O Mambaforge.sh https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh &&\ + chmod +x Mambaforge.sh &&\ + bash Mambaforge.sh -b -p /opt/miniconda &&\ + rm Mambaforge.sh SHELL ["/bin/bash", "-c"] RUN eval "$(/opt/miniconda/bin/conda shell.bash hook)" &&\ - conda env create -n mantidimaging_test -f https://raw.githubusercontent.com/mantidproject/mantidimaging/master/environment-dev.yml &&\ + mamba env create -n mantidimaging_test -f https://raw.githubusercontent.com/mantidproject/mantidimaging/master/environment-dev.yml &&\ conda activate mantidimaging_test &&\ - conda clean --all + mamba clean --all RUN mkdir /opt/mantidimaging diff --git a/docs/developer_guide/index.rst b/docs/developer_guide/index.rst index 4b50cbebdd5..6728ece0926 100644 --- a/docs/developer_guide/index.rst +++ b/docs/developer_guide/index.rst @@ -4,7 +4,7 @@ Developer Guide Getting Started --------------- -You will need conda, CUDA and gcc installed, see the :ref:`Installation` instructions. +You will need conda/mamba, CUDA and gcc installed, see the :ref:`Installation` instructions. First download the Mantid Imaging source code using Git. diff --git a/docs/installation.rst b/docs/installation.rst index 3982db03566..43f46eaac50 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -22,7 +22,7 @@ Installing ---------- The simplest way to install the toolkit is via the packages_ published to Anaconda Cloud, this -can be done with an existing Anaconda or Miniconda distribution if you already +can be done with an existing Conda or Mamba distribution if you already have one on your machine. .. _packages: https://anaconda.org/mantid/mantidimaging/ @@ -34,11 +34,11 @@ Please look for instructions specific to your OS on how to do that: - CUDA Runtime version 10.2 - https://developer.nvidia.com/cuda-10.2-download-archive - gcc - needed for compiling some python modules -2. Download and install `Miniconda 3 `_ -3. Make sure :code:`conda` is available on your PATH +2. Download and install `Mambaforge `_ or `Miniconda 3 `_ +3. Make sure :code:`mamba` or :code:`conda` is available on your PATH. The steps below assume you are using mamba. 4. Create a mantidimaging conda environment: - - :code:`conda env create -f https://raw.githubusercontent.com/mantidproject/mantidimaging/stable/environment.yml` + - :code:`mamba env create -f https://raw.githubusercontent.com/mantidproject/mantidimaging/stable/environment.yml` (Specific versions can be installed by using the release url, e.g. `https://raw.githubusercontent.com/mantidproject/mantidimaging/release-2.2.0/environment.yml`) @@ -70,7 +70,7 @@ Nightly version The latest nightly version can be installed with - - :code:`conda env create -f https://raw.githubusercontent.com/mantidproject/mantidimaging/master/environment.yml` + - :code:`mamba env create -f https://raw.githubusercontent.com/mantidproject/mantidimaging/master/environment.yml` This will make a `mantidimaging-nightly` environment. @@ -79,7 +79,7 @@ Updating -------- To update to the latest version of Mantid Imaging run: -:code:`conda activate mantidimaging && conda update mantidimaging` +:code:`conda activate mantidimaging && mamba update mantidimaging` If you see any issues with package compatibility, the fastest solution is reinstalling the environment - see below. @@ -91,11 +91,11 @@ To completely delete the Mantid Imaging environment follow these steps: - to exit out of the conda Mantid Imaging environment -- :code:`conda env list` +- :code:`mamba env list` - to see which environments you have installed -- :code:`conda env remove -n mantidimaging` +- :code:`mamba env remove -n mantidimaging` - and press :code:`y` to confirm. Replace `mantidimaging` with any other environment you wish to remove diff --git a/docs/release_notes/next.rst b/docs/release_notes/next.rst index 59f1da967a4..5c442e1724e 100644 --- a/docs/release_notes/next.rst +++ b/docs/release_notes/next.rst @@ -12,3 +12,9 @@ Fixes ----- - #1138 : Improve version number handling + + +Developer Changes +----------------- + +- #1022 : Switch to use Mambaforge diff --git a/environment-dev.yml b/environment-dev.yml index 66be9ed875f..aa0f6d65df1 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -5,7 +5,6 @@ channels: - astra-toolbox/label/dev - conda-forge - ccpi - - defaults dependencies: - mantidimaging - pip diff --git a/environment.yml b/environment.yml index 7d2833c3e41..3d9eb375371 100644 --- a/environment.yml +++ b/environment.yml @@ -5,7 +5,6 @@ channels: - astra-toolbox/label/dev - conda-forge - ccpi - - defaults # Dependencies that can be installed with conda should be in conda/meta.yaml dependencies: - mantidimaging diff --git a/setup.py b/setup.py index ed96d330162..2dda4af17ec 100644 --- a/setup.py +++ b/setup.py @@ -10,6 +10,7 @@ from collections import defaultdict from pathlib import Path import tempfile +import shutil from setuptools import find_packages, setup try: @@ -147,13 +148,21 @@ def run(self): class CreateDeveloperEnvironment(Command): description = "Install the dependencies needed to develop Mantid Imaging" - user_options = [] + user_options = [("conda=", None, "path to conda or mamba command")] def initialize_options(self): - pass + mamba_path = shutil.which("mamba") + conda_path = shutil.which("conda") + if mamba_path is not None: + self.conda = mamba_path + elif conda_path is not None: + self.conda = conda_path + else: + self.conda = None def finalize_options(self): - pass + if self.conda is None: + raise ValueError("Could not find conda or mamba") def count_indent(self, line): leading_spaces = len(line) - len(line.lstrip(" ")) @@ -193,12 +202,12 @@ def make_environment_file(self, extra_deps): def run(self): print("Removing existing mantidimaging-dev environment") - command_conda_env_remove = ["conda", "env", "remove", "-n", "mantidimaging-dev"] + command_conda_env_remove = [self.conda, "env", "remove", "-n", "mantidimaging-dev"] subprocess.check_call(command_conda_env_remove) extra_deps = self.get_package_depends() env_file_path = self.make_environment_file(extra_deps) print("Creating conda environment for development") - command_conda_env = ["conda", "env", "create", "-f", env_file_path] + command_conda_env = [self.conda, "env", "create", "-f", env_file_path] subprocess.check_call(command_conda_env) os.remove(env_file_path)