-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlce2java.bat
More file actions
66 lines (49 loc) · 1.68 KB
/
Copy pathlce2java.bat
File metadata and controls
66 lines (49 loc) · 1.68 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
@echo off
setlocal
:: LCE to Java World Converter - Windows Wrapper
:: Navigate to the directory where the script is located
cd /d "%~dp0"
set "VENV_DIR=.venv"
set "VENV_HASH_FILE=%VENV_DIR%\.venv_hash"
:: Check for python
where python >nul 2>nul
if %ERRORLEVEL% neq 0 (
echo Error: 'python' is not installed or not in PATH.
exit /b 1
)
:: Calculate hash of requirements using Python
for /f "delims=" %%i in ('python -c "import hashlib; print(hashlib.md5(open('requirements.txt', 'rb').read()).hexdigest())"') do set REQ_HASH=%%i
set "BUILD_VENV=0"
if not exist "%VENV_DIR%" set BUILD_VENV=1
if not exist "%VENV_HASH_FILE%" set BUILD_VENV=1
if "%BUILD_VENV%"=="0" (
set /p STORED_HASH=<"%VENV_HASH_FILE%"
)
if "%BUILD_VENV%"=="0" if not "%REQ_HASH%"=="%STORED_HASH%" (
echo =^> Dependencies updated. Rebuilding environment...
set BUILD_VENV=1
)
if "%BUILD_VENV%"=="1" (
echo =^> Creating Python virtual environment in %VENV_DIR%...
if exist "%VENV_DIR%" rmdir /s /q "%VENV_DIR%"
python -m venv "%VENV_DIR%"
if %ERRORLEVEL% neq 0 (
echo Error: Failed to create virtual environment.
if exist "%VENV_DIR%" rmdir /s /q "%VENV_DIR%"
exit /b 1
)
echo =^> Activating virtual environment and installing dependencies...
call "%VENV_DIR%\Scripts\activate.bat"
python -m pip install --upgrade pip
pip install -r requirements.txt
echo %REQ_HASH% > "%VENV_HASH_FILE%"
) else (
call "%VENV_DIR%\Scripts\activate.bat"
)
echo =^> Launching converter...
echo.
:: Execute the main Python script
python lce2java_main.py %*
:: Deactivate the virtual environment to leave the shell session clean
call deactivate
endlocal