-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_windows.bat
107 lines (87 loc) · 3.32 KB
/
start_windows.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
@echo off
cd /D "%~dp0"
set PATH=%PATH%;%SystemRoot%\system32
@rem Check if the current directory contains spaces
echo "%CD%" | findstr /C:" " >nul
if %errorlevel% equ 0 (
echo WARNING: This script relies on Miniconda which may not be silently installed under a path with spaces.
echo Proceeding with installation. Please ensure to check the installation afterward.
)
@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%
)
@rem Fix failed install when installing to a separate drive
set TMP=%cd%\installer_files
set TEMP=%cd%\installer_files
@rem Deactivate existing conda envs as needed to avoid conflicts
(call conda deactivate && call conda deactivate && call conda deactivate) 2>nul
@rem Configuration
set INSTALL_DIR=%cd%\installer_files
set CONDA_ROOT_PREFIX=%INSTALL_DIR%\conda
set INSTALL_ENV_DIR=%INSTALL_DIR%\env
set MINICONDA_DOWNLOAD_URL=https://repo.anaconda.com/miniconda/Miniconda3-py311_24.3.0-0-Windows-x86_64.exe
set conda_exists=F
@rem Check if conda is already installed
call "%CONDA_ROOT_PREFIX%\_conda.exe" --version >nul 2>&1
if "%ERRORLEVEL%" EQU "0" set conda_exists=T
@rem Download and install Miniconda if not already installed
if "%conda_exists%" == "F" (
echo Downloading Miniconda from %MINICONDA_DOWNLOAD_URL% to %INSTALL_DIR%\miniconda_installer.exe
mkdir "%INSTALL_DIR%"
curl -Lk "%MINICONDA_DOWNLOAD_URL%" -o "%INSTALL_DIR%\miniconda_installer.exe" || (
echo.
echo Miniconda failed to download.
goto end
)
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
)
)
@rem Remove Intel channel if it exists
call "%CONDA_ROOT_PREFIX%\_conda.exe" config --remove channels intel >nul 2>&1
@rem Create the installer environment
if not exist "%INSTALL_ENV_DIR%" (
echo Creating conda environment at %INSTALL_ENV_DIR%
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
)
)
@rem Check if conda environment was 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=
@rem Activate installer environment
call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%" || (
echo.
echo Miniconda hook not found.
goto end
)
@rem Setup installer environment
call python -W ignore one_click_gpu_updated.py %*
@rem Functions for the script
goto end
:PrintBigMessage
echo. && echo.
echo *******************************************************************
for %%M in (%*) do echo * %%~M
echo *******************************************************************
echo. && echo.
exit /b
:end
pause