Check for missing python/git before activating micromamba

This commit is contained in:
cmdr2 2022-10-12 16:53:07 +05:30 committed by tildebyte
parent 71426d200e
commit 74e6ce3e6a
2 changed files with 15 additions and 15 deletions

View File

@ -18,6 +18,15 @@ set INSTALL_ENV_DIR=%cd%\installer_files\env
set MICROMAMBA_BINARY_FILE=%cd%\installer_files\micromamba_win_x64.exe 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 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 @rem initialize micromamba
if not exist "%MAMBA_ROOT_PREFIX%" ( if not exist "%MAMBA_ROOT_PREFIX%" (
mkdir "%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" 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 @rem (if necessary) install git and python into a contained environment
if "%PACKAGES_TO_INSTALL%" NEQ "" ( if "%PACKAGES_TO_INSTALL%" NEQ "" (
echo "Packages to install: %PACKAGES_TO_INSTALL%" echo "Packages to install: %PACKAGES_TO_INSTALL%"

View File

@ -29,6 +29,12 @@ INSTALL_ENV_DIR="$(pwd)/installer_files/env"
MICROMAMBA_BINARY_FILE="$(pwd)/installer_files/micromamba_${OS_NAME}_${OS_ARCH}" 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 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 # initialize micromamba
mkdir -p "$MAMBA_ROOT_PREFIX" mkdir -p "$MAMBA_ROOT_PREFIX"
cp "$MICROMAMBA_BINARY_FILE" "$MAMBA_ROOT_PREFIX/micromamba" cp "$MICROMAMBA_BINARY_FILE" "$MAMBA_ROOT_PREFIX/micromamba"
@ -40,12 +46,6 @@ echo Micromamba version:
# run the shell hook, otherwise activate will fail # run the shell hook, otherwise activate will fail
eval "$($MAMBA_ROOT_PREFIX/micromamba shell hook -s posix)" 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) # install git and python into a contained environment (if necessary)
if [ "$PACKAGES_TO_INSTALL" != "" ]; then if [ "$PACKAGES_TO_INSTALL" != "" ]; then
echo "Packages to install: $PACKAGES_TO_INSTALL" echo "Packages to install: $PACKAGES_TO_INSTALL"