-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_windows.bat
More file actions
95 lines (81 loc) · 2.43 KB
/
Copy pathupdate_windows.bat
File metadata and controls
95 lines (81 loc) · 2.43 KB
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
@echo off
setlocal enabledelayedexpansion
if not defined in_subprocess (cmd /k set in_subprocess=y ^& %0 %*) & exit
:: Change to project directory
cd /d "%~dp0"
if %errorlevel% neq 0 (
echo Failed to change to project directory.
goto end
)
:: Ensure Git is installed and in PATH
where git >nul 2>nul
if errorlevel 1 (
echo Git is not installed or not found in PATH. Please install Git and ensure it's in your PATH.
goto end
)
:: Ensure Miniconda/Anaconda is installed and conda is in PATH
where conda >nul 2>nul
if errorlevel 1 (
echo Conda is not installed or not found in PATH. Please install Miniconda/Anaconda and ensure conda is in your PATH.
goto end
)
:: Define environment name and Python version
set ENV_NAME=taleweaver
set PYTHON_VERSION=3.12.4
:: Deactivate any active conda environment
call conda deactivate
:: Check if the environment exists, if not create it
call conda env list | findstr /C:"%ENV_NAME%" >nul
if %errorlevel% neq 0 (
echo Creating conda environment %ENV_NAME% with Python %PYTHON_VERSION%
call conda create -y -n %ENV_NAME% python=%PYTHON_VERSION%
if %errorlevel% neq 0 (
echo Failed to create conda environment.
goto end
)
) else (
echo Conda environment %ENV_NAME% already exists.
)
:: Activate the conda environment
call conda activate %ENV_NAME%
if %errorlevel% neq 0 (
echo Failed to activate conda environment %ENV_NAME%.
goto end
)
:: Get current branch name
for /f "tokens=*" %%i in ('git rev-parse --abbrev-ref HEAD') do set BRANCH_NAME=%%i
echo Current branch: %BRANCH_NAME%
:: Check for Git updates
echo Checking for updates...
git fetch origin
if %errorlevel% neq 0 (
echo Failed to fetch updates from remote.
goto end
)
git status -uno | findstr "Your branch is up to date" >nul
if %errorlevel% neq 0 (
echo Updates available. Pulling changes...
git pull origin %BRANCH_NAME%
if %errorlevel% neq 0 (
echo Failed to pull updates.
goto end
)
:: Reinstall requirements in case they've changed
if exist requirements.txt (
echo Updating requirements...
pip install -r requirements.txt
if %errorlevel% neq 0 (
echo Failed to update requirements.
goto end
)
)
echo Update complete.
) else (
echo Your project is up to date.
)
:: Deactivate conda environment before exit
call conda deactivate
:end
echo Script execution completed.
pause
endlocal