-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_env.bat
More file actions
102 lines (88 loc) · 2.56 KB
/
setup_env.bat
File metadata and controls
102 lines (88 loc) · 2.56 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
96
97
98
99
100
101
102
@echo off
setlocal
:: SubtitleExtractor CPU baseline setup.
:: Optional overrides:
:: set SUBTITLE_EXTRACTOR_ENV=my-env
:: set CONDA_EXE=C:\Path\To\conda.exe
set "ENV_NAME=subtitle-extractor"
if defined SUBTITLE_EXTRACTOR_ENV set "ENV_NAME=%SUBTITLE_EXTRACTOR_ENV%"
set "PIP_CONSTRAINT_ARGS="
if exist "constraints.txt" set "PIP_CONSTRAINT_ARGS=-c constraints.txt"
call :find_conda
if errorlevel 1 (
pause
exit /b 1
)
echo Using Conda: %CONDA%
echo Environment: %ENV_NAME%
if defined PIP_CONSTRAINT_ARGS echo Pip constraints: constraints.txt
echo.
echo [1/4] Ensuring conda environment (Python 3.11)...
call "%CONDA%" env list | findstr /R /C:"^%ENV_NAME%[ ]" >nul 2>nul
if errorlevel 1 (
call "%CONDA%" create -n "%ENV_NAME%" python=3.11 -y
if errorlevel 1 (
echo Failed to create conda environment.
pause
exit /b 1
)
) else (
echo Environment already exists, skipping creation.
)
echo [2/4] Installing CPU baseline dependencies...
call :run_python -m pip install --upgrade pip
if errorlevel 1 goto :pip_failed
call :run_python -m pip install -r requirements.txt %PIP_CONSTRAINT_ARGS%
if errorlevel 1 goto :pip_failed
echo [3/4] Installing development verification tools...
call :run_python -m pip install -r requirements-dev.txt %PIP_CONSTRAINT_ARGS%
if errorlevel 1 goto :pip_failed
echo [4/4] Verifying PaddleOCR baseline imports...
call :run_python -c "import paddleocr, paddle; print('PaddleOCR:', paddleocr.__version__, '| paddle:', paddle.__version__)"
if errorlevel 1 (
echo Baseline import verification failed.
pause
exit /b 1
)
echo.
echo Done. Start the service with:
echo start.bat
echo.
echo Download ffmpeg.exe and yt-dlp.exe before first extraction:
echo powershell -ExecutionPolicy Bypass -File scripts\download_tools.ps1
echo.
echo Optional ASR setup:
echo setup_asr_cuda.bat
pause
exit /b 0
:pip_failed
echo Dependency installation failed.
pause
exit /b 1
:run_python
call "%CONDA%" run -n "%ENV_NAME%" python %*
exit /b %ERRORLEVEL%
:find_conda
if defined CONDA_EXE (
if exist "%CONDA_EXE%" (
set "CONDA=%CONDA_EXE%"
exit /b 0
)
)
for /f "delims=" %%I in ('where conda 2^>nul') do (
set "CONDA=%%I"
exit /b 0
)
for %%I in (
"%USERPROFILE%\miniconda3\Scripts\conda.exe"
"%USERPROFILE%\anaconda3\Scripts\conda.exe"
"C:\ProgramData\miniconda3\Scripts\conda.exe"
"C:\ProgramData\Anaconda3\Scripts\conda.exe"
) do (
if exist "%%~I" (
set "CONDA=%%~I"
exit /b 0
)
)
echo Conda was not found. Install Miniconda/Anaconda or set CONDA_EXE.
exit /b 1