Skip to content

Commit 0c40a6c

Browse files
committed
run.bat/run.sh updated, added separate init.sh/init.bat scripts
1 parent cb5816b commit 0c40a6c

4 files changed

Lines changed: 67 additions & 4 deletions

File tree

init.bat

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@echo off
2+
setlocal enabledelayedexpansion
3+
4+
set "script_dir=%~dp0"
5+
set "base_dir=%CD%\"
6+
REM set "base_dir=%script_dir%"
7+
8+
REM This value will be used with UV to install corresponding python version, may be overriden by params.bat
9+
set "USE_PYTHON_VER=3.14"
10+
11+
if exist "%script_dir%params.bat" (
12+
echo Loading %script_dir%params.bat
13+
call "%script_dir%params.bat"
14+
)
15+
16+
set "py_dir=%base_dir%py_dist"
17+
echo Using Python base directory: %py_dir%
18+
19+
echo Installing and upgrading python distribution and venv using UV
20+
set "UV_COMPILE_BYTECODE=0"
21+
set "UV_PYTHON_INSTALL_REGISTRY=0"
22+
set "UV_PYTHON_BIN_DIR=%py_dir%\python_bin"
23+
set "UV_PYTHON_INSTALL_DIR=%py_dir%\dists"
24+
set "UV_TOOL_BIN_DIR=%py_dir%\tool_bin"
25+
set "UV_TOOL_DIR=%py_dir%\tool"
26+
set "UV_CACHE_DIR=%py_dir%\cache"
27+
set "UV_LINK_MODE=copy"
28+
29+
uv python install --upgrade %USE_PYTHON_VER%
30+
if %errorlevel% neq 0 exit /b %errorlevel%
31+
32+
set "venv_dir=%base_dir%venv"
33+
echo Using venv directory: %venv_dir%
34+
35+
if not exist "%venv_dir%" (
36+
uv venv "%venv_dir%"
37+
if %errorlevel% neq 0 exit /b %errorlevel%
38+
)
39+
40+
echo Cleaning up cache
41+
RMDIR /S /Q "%py_dir%\cache"
42+
43+
echo Install complete
44+
endlocal
45+
pause

init.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e
3+
4+
script_dir="$(cd "$(dirname "$0")" && pwd)"
5+
venv_dir="$script_dir/venv"
6+
echo "Using venv directory: $venv_dir"
7+
8+
if [[ ! -d "$venv_dir" ]]; then
9+
python3 -m venv "$venv_dir"
10+
fi
11+
12+
echo "Install complete"

run.bat

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ set "script_dir=%~dp0"
55
set "venv_dir=%script_dir%venv"
66

77
if not exist "%venv_dir%" (
8-
python3 -m venv "%venv_dir%"
9-
"%venv_dir%\Scripts\python" -m pip --require-virtualenv install --upgrade pip build
8+
echo No venv directory found, run init.bat to initialize it...
9+
pause
10+
exit /b 1
1011
)
1112

13+
echo Activating venv
14+
call "%venv_dir%\Scripts\activate.bat"
15+
1216
"%venv_dir%\Scripts\python" %*
1317

1418
endlocal

run.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ script_dir="$(cd "$(dirname "$0")" && pwd)"
55
venv_dir="$script_dir/venv"
66

77
if [[ ! -d "$venv_dir" ]]; then
8-
python3 -m venv "$venv_dir"
9-
"$venv_dir/bin/python" -m pip --require-virtualenv install --upgrade pip build
8+
echo "virtual env missing, run init.sh first!"
9+
exit 1
1010
fi
1111

12+
. "$venv_dir/bin/activate"
13+
1214
"$venv_dir/bin/python" "$@"

0 commit comments

Comments
 (0)