Skip to content

Commit

Permalink
Merge pull request #839 from SyneRBI/conda-libmamba-solver
Browse files Browse the repository at this point in the history
revert to `conda` but with `libmamba` solver
  • Loading branch information
KrisThielemans authored Mar 22, 2024
2 parents 4608194 + 44a35f5 commit d7291d7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- The `devel` tag (for `DEVEL_BUILD=ON` with `master` versions of SIRF, STIR etc) is no longer pushed to DockerHub, and therefore will not be updated.
- Docker images are now pushed to [DockerHub](https://hub.docker.com/r/synerbi/sirf/tags) and [GHCR](https://github.com/SyneRBI/SIRF-SuperBuild/pkgs/container/sirf)
- added requirements.yml
- revert to `conda` but with `libmamba` solver
- updated versions:
- SIRF: v3.6.0
- STIR: v6.0.0
Expand Down Expand Up @@ -41,7 +42,7 @@
- docker image updates
- introduce `REMOVE_BUILD_FILES` variable. If set to 1 (which is the default),
most build files will be removed in the docker image.
- introduce `RUN_CTESTS` variable. If set to 1 (which is the default),
- introduce `RUN_CTEST` variable. If set to 1 (which is the default),
the CTests will be run while building the image.
- remove obsolete copying of gadgetron.xml
- Installing requirements for SIRF-Exercises uses its environment.yml or requirements.txt depending on settings.
Expand Down
12 changes: 6 additions & 6 deletions docker/install-sirf-exercises-dep.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import functools

def conda_install(package):
return f'mamba install -y -c conda-forge {package}'.rstrip()
return f'conda install -y -c conda-forge {package}'.rstrip()

def pip_install(package):
return f'pip install -U {package}'.rstrip()
Expand All @@ -30,18 +30,18 @@ def pip_install(package):
else:
print (f'Not on conda-forge: {line.rstrip()}')
install_by_pip.append(line.rstrip())

install_by_conda = functools.reduce(lambda x, y: x + ' ' + y, install_by_conda, '')


install_by_pip = functools.reduce(lambda x, y: x + ' ' + y, install_by_pip, '')


try:
print ("Installing from conda-forge:", install_by_conda)
subprocess.run(conda_install(install_by_conda), shell=True, check=True)
print ("Installing from PyPI:", install_by_pip)
subprocess.run([sys.executable, "-m", pip_install(install_by_pip)], shell=True, check=True)

except subprocess.CalledProcessError as cpe:
print (cpe)
print (cpe)
4 changes: 2 additions & 2 deletions docker/user_demos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ if [ "$PYTHON" = "miniconda" ]; then
# delete GPU deps
sed -r -e '/^\s*- (astra-toolbox|tigre).*/d' -e '/^\s*- \S+.*#.*GPU/d' environment.yml > environment-sirf.yml
fi
mamba env update --file environment-sirf.yml
conda env update --file environment-sirf.yml
else
if [ -f requirements.txt ]; then
cat requirements.txt
# installing the requirements.txt with mamba requires some cleaning of the requirements.txt
# installing the requirements.txt with conda requires some cleaning of the requirements.txt
# Also the requirements.txt contains some packages that are not found on conda-forge, i.e. brainweb
# Therefore, these need to be installed by pip.
# This is handled by the install-sirf-exercises-dep.py script
Expand Down
22 changes: 9 additions & 13 deletions docker/user_python-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env bash

# User can pass 2 parameters to this script:
# User can pass 2 parameters to this script:
# 1. PYTHON_EXECUTABLE which can be either the 'miniconda' string or the location of the Python executable
# 2. PYTHON_INSTALL_DIR which points to the location where the user has their virtual environment installed
# The virtual environment can be either virtualenv or conda
#
# To pass these parameters the user needs to set (at least) temporary environment variables:
# PYTHON_EXECUTABLE=python3 PYTHON_INSTALL_DIR="~/virtualenv" bash user_python-ubuntu.sh
# For details see https://github.com/SyneRBI/SIRF-SuperBuild/pull/692#issuecomment-1102704682
# For details see https://github.com/SyneRBI/SIRF-SuperBuild/pull/692#issuecomment-1102704682
[ -f .bashrc ] && . .bashrc
set -exv

if [ -n "${PYTHON_EXECUTABLE}" ]; then
if [ -n "${PYTHON_EXECUTABLE}" ]; then
PYTHON=$PYTHON_EXECUTABLE
else
PYTHON='miniconda'
Expand All @@ -26,16 +26,12 @@ fi
# Python
case "$PYTHON" in
miniconda)
#curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > miniconda.sh
curl -L https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh > miniconda.sh
curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > miniconda.sh
echo -e "\nyes\n${INSTALL_DIR}\nno" | bash miniconda.sh
rm miniconda.sh
source "$INSTALL_DIR"/bin/activate
#conda config --add channels conda-forge
# https://github.com/conda/conda/issues/6030
#conda update -c conda-forge -y conda
# https://github.com/SyneRBI/SIRF-SuperBuild/issues/826
#conda install -c conda-forge -c defaults -y mamba
conda config --add channels conda-forge
conda update -c conda-forge -y conda
;;
*python*)
# virtualenv
Expand All @@ -54,11 +50,11 @@ esac

if [ "$PYTHON" = "miniconda" ]; then
if [ -f requirements.yml ]; then
# installs the required packages in the environment with requirements.yml.
# installs the required packages in the environment with requirements.yml.
# Notice that SciPy is set to 1.7.3 to prevent `GLIBCXX_3.4.30' not found
mamba env update --file requirements.yml
conda env update --file requirements.yml
fi
mamba clean -y --all
conda clean -y --all
# Python (runtime)
else
if [ -f requirements.txt ]; then
Expand Down

0 comments on commit d7291d7

Please sign in to comment.