From 74e6ce3e6ac71e038d5cfda78ff933df238b7a7d Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Oct 2022 16:53:07 +0530 Subject: [PATCH] Check for missing python/git before activating micromamba --- installer/install.bat | 18 +++++++++--------- installer/install.sh | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/installer/install.bat b/installer/install.bat index 806e6ea745..a1ca837607 100644 --- a/installer/install.bat +++ b/installer/install.bat @@ -18,6 +18,15 @@ set INSTALL_ENV_DIR=%cd%\installer_files\env set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe set PATH=%PATH%;%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts +@rem figure out whether git and python needs to be installed +set PACKAGES_TO_INSTALL= + +call python --version "" >tmp/stdout.txt 2>tmp/stderr.txt +if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% python + +call git --version "" >tmp/stdout.txt 2>tmp/stderr.txt +if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git + @rem initialize micromamba if not exist "%MAMBA_ROOT_PREFIX%" ( mkdir "%MAMBA_ROOT_PREFIX%" @@ -35,15 +44,6 @@ if not exist "%MAMBA_ROOT_PREFIX%" ( call "%MAMBA_ROOT_PREFIX%\condabin\mamba_hook.bat" -@rem figure out whether git and python needs to be installed -set PACKAGES_TO_INSTALL= - -call python --version "" >tmp/stdout.txt 2>tmp/stderr.txt -if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% python - -call git --version "" >tmp/stdout.txt 2>tmp/stderr.txt -if "%ERRORLEVEL%" NEQ "0" set PACKAGES_TO_INSTALL=%PACKAGES_TO_INSTALL% git - @rem (if necessary) install git and python into a contained environment if "%PACKAGES_TO_INSTALL%" NEQ "" ( echo "Packages to install: %PACKAGES_TO_INSTALL%" diff --git a/installer/install.sh b/installer/install.sh index 569a4fc47a..6bf606497e 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -29,6 +29,12 @@ INSTALL_ENV_DIR="$(pwd)/installer_files/env" MICROMAMBA_BINARY_FILE="$(pwd)/installer_files/micromamba_${OS_NAME}_${OS_ARCH}" if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$PATH;$INSTALL_ENV_DIR/bin"; fi +# figure out what needs to be installed +PACKAGES_TO_INSTALL="" + +if ! hash "python" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL python"; fi +if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi + # initialize micromamba mkdir -p "$MAMBA_ROOT_PREFIX" cp "$MICROMAMBA_BINARY_FILE" "$MAMBA_ROOT_PREFIX/micromamba" @@ -40,12 +46,6 @@ echo Micromamba version: # run the shell hook, otherwise activate will fail eval "$($MAMBA_ROOT_PREFIX/micromamba shell hook -s posix)" -# figure out what needs to be installed -PACKAGES_TO_INSTALL="" - -if ! hash "python" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL python"; fi -if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi - # install git and python into a contained environment (if necessary) if [ "$PACKAGES_TO_INSTALL" != "" ]; then echo "Packages to install: $PACKAGES_TO_INSTALL"