-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean_venv_setup.bat
More file actions
92 lines (80 loc) · 2.36 KB
/
Copy pathclean_venv_setup.bat
File metadata and controls
92 lines (80 loc) · 2.36 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
@echo off
setlocal EnableDelayedExpansion
echo ============================================
echo JPyRust Clean Python Environment Setup
echo ============================================
echo.
set "TEMP_DIR=C:\jpyrust_temp"
set "VENV_DIR=%TEMP_DIR%\venv"
set "PYTHON_EXE=%TEMP_DIR%\python.exe"
REM Step 1: Check if bundled Python exists
echo [Step 1/4] Checking bundled Python...
if not exist "%PYTHON_EXE%" (
echo ERROR: Bundled Python not found at %PYTHON_EXE%
echo Please ensure the Python distribution is extracted to %TEMP_DIR%
pause
exit /b 1
)
REM Get Python version
echo Python location: %PYTHON_EXE%
"%PYTHON_EXE%" --version
echo.
REM Step 2: Force delete existing venv
echo [Step 2/4] Deleting existing virtual environment...
if exist "%VENV_DIR%" (
echo Found existing venv at %VENV_DIR%
echo Removing... (this may take a moment)
rmdir /s /q "%VENV_DIR%" 2>nul
if exist "%VENV_DIR%" (
echo WARNING: Standard removal failed, attempting force delete...
del /f /s /q "%VENV_DIR%\*" >nul 2>&1
rmdir /s /q "%VENV_DIR%" 2>nul
)
if not exist "%VENV_DIR%" (
echo Successfully deleted old venv.
) else (
echo ERROR: Could not delete %VENV_DIR%
echo Please close any programs using this folder and try again.
pause
exit /b 1
)
) else (
echo No existing venv found. Clean slate!
)
echo.
REM Step 3: Create new venv
echo [Step 3/4] Creating new virtual environment...
"%PYTHON_EXE%" -m venv "%VENV_DIR%"
if errorlevel 1 (
echo ERROR: Failed to create virtual environment.
pause
exit /b 1
)
echo Virtual environment created successfully.
echo.
REM Step 4: Install dependencies
echo [Step 4/4] Installing dependencies with fresh cache...
echo Using --no-cache-dir and --force-reinstall to ensure clean binaries.
echo.
call "%VENV_DIR%\Scripts\activate.bat"
pip install --no-cache-dir --force-reinstall ultralytics numpy opencv-python-headless
if errorlevel 1 (
echo.
echo ERROR: pip install failed!
pause
exit /b 1
)
echo.
echo ============================================
echo Setup Complete!
echo ============================================
echo.
echo Virtual environment: %VENV_DIR%
echo.
echo To activate manually, run:
echo %VENV_DIR%\Scripts\activate.bat
echo.
echo Python packages installed:
pip list | findstr /i "ultralytics numpy opencv"
echo.
pause