Skip to content

Commit

Permalink
Merge pull request #1141 from mantidproject/1022-mambaforge
Browse files Browse the repository at this point in the history
Switch actions to use Mambaforge
  • Loading branch information
DolicaAkelloEgwel authored Sep 17, 2021
2 parents 0463058 + a51f042 commit 43b367b
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 24 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ jobs:
- name: Check License Lines
uses: kt3k/[email protected]

- 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
Expand Down
12 changes: 6 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/developer_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
16 changes: 8 additions & 8 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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 <https://conda.io/miniconda.html>`_
3. Make sure :code:`conda` is available on your PATH
2. Download and install `Mambaforge <https://github.com/conda-forge/miniforge>`_ or `Miniconda 3 <https://conda.io/miniconda.html>`_
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`)

Expand Down Expand Up @@ -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.

Expand All @@ -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.

Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions docs/release_notes/next.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ Fixes
-----

- #1138 : Improve version number handling


Developer Changes
-----------------

- #1022 : Switch to use Mambaforge
1 change: 0 additions & 1 deletion environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ channels:
- astra-toolbox/label/dev
- conda-forge
- ccpi
- defaults
dependencies:
- mantidimaging
- pip
Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 14 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from collections import defaultdict
from pathlib import Path
import tempfile
import shutil

from setuptools import find_packages, setup
try:
Expand Down Expand Up @@ -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(" "))
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 43b367b

Please sign in to comment.