Skip to content

Commit

Permalink
TFinder_standalone_win.bat
Browse files Browse the repository at this point in the history
  • Loading branch information
Jumitti committed Dec 13, 2024
1 parent 3c7d9a4 commit 874f381
Showing 1 changed file with 50 additions and 30 deletions.
80 changes: 50 additions & 30 deletions TFinder_standalone_win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,56 @@ echo %COLOR_YELLOW%Created by Minniti Julien%COLOR_RESET% - %COLOR_BLUE%GitHub(%
echo %COLOR_YELLOW%MIT Licence%COLOR_RESET% - %COLOR_BLUE%https://github.com/Jumitti/TFinder/blob/main/LICENSE%COLOR_RESET%
echo %COLOR_GREEN%======================================================================================================%COLOR_RESET%

:: Check if Python 3.11.9 is installed
echo %COLOR_CYAN%Checking for Python 3.11.9 installation...%COLOR_RESET%
python --version | find "3.11.9" >nul 2>&1
if %errorlevel% neq 0 (
echo %COLOR_YELLOW%Python 3.11.9 is not installed.%COLOR_RESET%
echo %COLOR_CYAN%Downloading and installing Python 3.11.9...%COLOR_RESET%
:: Check if Python >= 3.10 is installed
echo %COLOR_CYAN%Checking for Python version higher or equal to 3.10...%COLOR_RESET%
for /f "usebackq tokens=2 delims= " %%v in (`python --version`) do set PYTHON_VERSION=%%v

:: Download the Python 3.11.9 installer (Windows x64)
powershell -Command "Invoke-WebRequest -Uri https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe -OutFile python-3.11.9-amd64.exe"
if exist python-3.11.9-amd64.exe (
echo %COLOR_CYAN%Running Python installer...(may be long)%COLOR_RESET%
start /wait python-3.11.9-amd64.exe /quiet InstallAllUsers=1 PrependPath=1
del python-3.11.9-amd64.exe
) else (
echo %COLOR_RED%Failed to download Python installer. Check your internet connection.%COLOR_RESET%
pause
exit /b
)

:: Check again if Python 3.11.9 is installed
python --version | find "3.11.9" >nul 2>&1
if %errorlevel% neq 0 (
echo %COLOR_RED%Python 3.11.9 installation failed. Please install it manually.%COLOR_RESET%
pause
exit /b
)
echo %COLOR_GREEN%Python 3.11.9 installed successfully! %COLOR_RESET%
:: Extract major and minor version numbers
for /f "tokens=1,2 delims=." %%a in ("%PYTHON_VERSION%") do (
set MAJOR=%%a
set MINOR=%%b
)

:: Check if version is >= 3.10
if not defined MAJOR (
echo %COLOR_RED%Python is not installed.%COLOR_RESET%
goto install_python
)

if %MAJOR% lss 3 (
echo %COLOR_RED%Python version is less than 3.10.%COLOR_RESET%
goto install_python
) else if %MAJOR% equ 3 if %MINOR% lss 10 (
echo %COLOR_RED%Python version is less than 3.10.%COLOR_RESET%
goto install_python
)

echo %COLOR_GREEN%Python version %PYTHON_VERSION% is sufficient.%COLOR_RESET%
goto continue

:install_python
echo %COLOR_YELLOW%Installing Python 3.11.9 from https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe...%COLOR_RESET%
powershell -Command "Invoke-WebRequest -Uri https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe -OutFile \"python-3.11.9-amd64.exe\""
if exist "python-3.11.9-amd64.exe" (
echo %COLOR_CYAN%Running Python installer...%COLOR_RESET%
start /wait "python-3.11.9-amd64.exe" /quiet InstallAllUsers=1 PrependPath=1
del "python-3.11.9-amd64.exe"
) else (
echo %COLOR_RED%Failed to download Python installer. Check your internet connection.%COLOR_RESET%
pause
exit /b
)

:: Verify the new installation
python --version | findstr /r "3\.[1-9][0-9]*" >nul 2>&1
if %errorlevel% neq 0 (
echo %COLOR_RED%Python installation failed. Please install it manually by downloading on https://www.python.org/ftp/python/3.11.9/python-3.11.9-amd64.exe.%COLOR_RESET%
pause
exit /b
)
echo %COLOR_GREEN%Python 3.11.9 installed successfully! %COLOR_RESET%

:continue
:: Virtual environment creation
if not exist ".venv" (
echo %COLOR_CYAN%Creating Python 3.11.9 virtual environment...%COLOR_RESET%
Expand All @@ -64,8 +85,8 @@ if not exist ".venv" (
pause
exit /b
)
echo %COLOR_GREEN%Virtual environment created successfully! %COLOR_RESET%
)
echo %COLOR_GREEN%Virtual environment created successfully! %COLOR_RESET%

:: Activation venv
echo %COLOR_CYAN%Activating virtual environment...%COLOR_RESET%
Expand All @@ -79,8 +100,7 @@ echo %COLOR_GREEN%Virtual environment activated successfully! %COLOR_RESET%

:: Updating pip and installing dependencies
echo %COLOR_CYAN%Installing/updating Python packages...%COLOR_RESET%
pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements.txt --verbose
if %errorlevel% neq 0 (
echo %COLOR_RED%Failed to install required packages. Check the requirements.txt file.%COLOR_RESET%
pause
Expand All @@ -89,7 +109,7 @@ if %errorlevel% neq 0 (
echo %COLOR_GREEN%Python packages installed successfully! %COLOR_RESET%

:: Run Streamlit/TFinder
echo %COLOR_CYAN%Launching the TFinder Streamlit app... (CTRL + C to shutdown)%COLOR_RESET%
echo %COLOR_CYAN%Launching the TFinder Streamlit app... (CTRL + C to shutdown) %COLOR_RESET%
streamlit run TFinder-v1.py
if %errorlevel% neq 0 (
echo %COLOR_RED%Failed to launch the Streamlit app. Check your script for errors.%COLOR_RESET%
Expand Down

0 comments on commit 874f381

Please sign in to comment.