2023-09-21 18:35:53 -04:00
|
|
|
@echo off
|
2024-03-09 19:33:12 -05:00
|
|
|
setlocal enabledelayedexpansion
|
2023-09-21 18:35:53 -04:00
|
|
|
|
|
|
|
cd /D "%~dp0"
|
|
|
|
|
|
|
|
set PATH=%PATH%;%SystemRoot%\system32
|
|
|
|
|
|
|
|
echo "%CD%"| findstr /C:" " >nul && echo This script relies on Miniconda which can not be silently installed under a path with spaces. && goto end
|
|
|
|
|
|
|
|
@rem Check for special characters in installation path
|
|
|
|
set "SPCHARMESSAGE="WARNING: Special characters were detected in the installation path!" " This can cause the installation to fail!""
|
|
|
|
echo "%CD%"| findstr /R /C:"[!#\$%&()\*+,;<=>?@\[\]\^`{|}~]" >nul && (
|
|
|
|
call :PrintBigMessage %SPCHARMESSAGE%
|
|
|
|
)
|
|
|
|
set SPCHARMESSAGE=
|
|
|
|
|
|
|
|
@rem fix failed install when installing to a separate drive
|
|
|
|
set TMP=%cd%\installer_files
|
|
|
|
set TEMP=%cd%\installer_files
|
|
|
|
|
2023-09-21 22:52:29 -04:00
|
|
|
@rem deactivate existing conda envs as needed to avoid conflicts
|
2023-09-23 07:33:44 -04:00
|
|
|
(call conda deactivate && call conda deactivate && call conda deactivate) 2>nul
|
2023-09-21 22:52:29 -04:00
|
|
|
|
2023-09-21 18:35:53 -04:00
|
|
|
@rem config
|
|
|
|
set INSTALL_DIR=%cd%\installer_files
|
|
|
|
set CONDA_ROOT_PREFIX=%cd%\installer_files\conda
|
|
|
|
set INSTALL_ENV_DIR=%cd%\installer_files\env
|
|
|
|
set MINICONDA_DOWNLOAD_URL=https://repo.anaconda.com/miniconda/Miniconda3-py310_23.3.1-0-Windows-x86_64.exe
|
2024-03-09 19:33:12 -05:00
|
|
|
set MINICONDA_CHECKSUM=307194e1f12bbeb52b083634e89cc67db4f7980bd542254b43d3309eaf7cb358
|
2023-09-21 18:35:53 -04:00
|
|
|
set conda_exists=F
|
|
|
|
|
|
|
|
@rem figure out whether git and conda needs to be installed
|
|
|
|
call "%CONDA_ROOT_PREFIX%\_conda.exe" --version >nul 2>&1
|
|
|
|
if "%ERRORLEVEL%" EQU "0" set conda_exists=T
|
|
|
|
|
|
|
|
@rem (if necessary) install git and conda into a contained environment
|
|
|
|
@rem download conda
|
|
|
|
if "%conda_exists%" == "F" (
|
|
|
|
echo Downloading Miniconda from %MINICONDA_DOWNLOAD_URL% to %INSTALL_DIR%\miniconda_installer.exe
|
|
|
|
|
|
|
|
mkdir "%INSTALL_DIR%"
|
2024-03-06 09:46:50 -05:00
|
|
|
call curl -Lk "%MINICONDA_DOWNLOAD_URL%" > "%INSTALL_DIR%\miniconda_installer.exe" || ( echo. && echo Miniconda failed to download. && goto end )
|
2023-09-21 18:35:53 -04:00
|
|
|
|
2024-03-09 19:33:12 -05:00
|
|
|
for /f %%a in ('CertUtil -hashfile "%INSTALL_DIR%\miniconda_installer.exe" SHA256 ^| find /i /v " " ^| find /i "%MINICONDA_CHECKSUM%"') do (
|
|
|
|
set "output=%%a"
|
|
|
|
)
|
|
|
|
|
|
|
|
if not defined output (
|
|
|
|
echo The checksum verification for miniconda_installer.exe has failed.
|
|
|
|
del "%INSTALL_DIR%\miniconda_installer.exe"
|
|
|
|
goto end
|
|
|
|
) else (
|
|
|
|
echo The checksum verification for miniconda_installer.exe has passed successfully.
|
|
|
|
)
|
|
|
|
|
2023-09-21 18:35:53 -04:00
|
|
|
echo Installing Miniconda to %CONDA_ROOT_PREFIX%
|
|
|
|
start /wait "" "%INSTALL_DIR%\miniconda_installer.exe" /InstallationType=JustMe /NoShortcuts=1 /AddToPath=0 /RegisterPython=0 /NoRegistry=1 /S /D=%CONDA_ROOT_PREFIX%
|
|
|
|
|
|
|
|
@rem test the conda binary
|
|
|
|
echo Miniconda version:
|
|
|
|
call "%CONDA_ROOT_PREFIX%\_conda.exe" --version || ( echo. && echo Miniconda not found. && goto end )
|
2024-03-04 11:11:03 -05:00
|
|
|
|
2024-03-09 19:33:12 -05:00
|
|
|
@rem delete the Miniconda installer
|
|
|
|
del "%INSTALL_DIR%\miniconda_installer.exe"
|
2023-09-21 18:35:53 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
@rem create the installer env
|
|
|
|
if not exist "%INSTALL_ENV_DIR%" (
|
|
|
|
echo Packages to install: %PACKAGES_TO_INSTALL%
|
2023-10-21 02:46:23 -04:00
|
|
|
call "%CONDA_ROOT_PREFIX%\_conda.exe" create --no-shortcuts -y -k --prefix "%INSTALL_ENV_DIR%" python=3.11 || ( echo. && echo Conda environment creation failed. && goto end )
|
2023-09-21 18:35:53 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
@rem check if conda environment was actually created
|
|
|
|
if not exist "%INSTALL_ENV_DIR%\python.exe" ( echo. && echo Conda environment is empty. && goto end )
|
|
|
|
|
|
|
|
@rem environment isolation
|
|
|
|
set PYTHONNOUSERSITE=1
|
|
|
|
set PYTHONPATH=
|
|
|
|
set PYTHONHOME=
|
|
|
|
set "CUDA_PATH=%INSTALL_ENV_DIR%"
|
|
|
|
set "CUDA_HOME=%CUDA_PATH%"
|
|
|
|
|
|
|
|
@rem activate installer env
|
|
|
|
call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%" || ( echo. && echo Miniconda hook not found. && goto end )
|
|
|
|
|
|
|
|
@rem setup installer env
|
2023-09-22 15:00:06 -04:00
|
|
|
call python one_click.py %*
|
2023-09-21 18:35:53 -04:00
|
|
|
|
|
|
|
@rem below are functions for the script next line skips these during normal execution
|
|
|
|
goto end
|
|
|
|
|
|
|
|
:PrintBigMessage
|
|
|
|
echo. && echo.
|
|
|
|
echo *******************************************************************
|
|
|
|
for %%M in (%*) do echo * %%~M
|
|
|
|
echo *******************************************************************
|
|
|
|
echo. && echo.
|
|
|
|
exit /b
|
|
|
|
|
|
|
|
:end
|
|
|
|
pause
|