-
Notifications
You must be signed in to change notification settings - Fork 27
/
windows-uninstall.bat
49 lines (41 loc) · 1.21 KB
/
windows-uninstall.bat
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
@echo off
setlocal enabledelayedexpansion
:: Display warning message
echo WARNING this uninstalls *** ALL *** python libraries
echo WARNING this deletes the poetry.lock file
echo Are you sure you want to continue? y/N
set /p user_input=
:: Check user input
if /i "%user_input%"=="y" (
echo Uninstalling Python libraries...
pip freeze > installed_packages.txt
:: Check if installed_packages.txt is empty
for %%A in (installed_packages.txt) do (
if %%~zA==0 (
echo all pip packages uninstalled
goto poetry_check
)
)
pip uninstall -r installed_packages.txt -y
goto poetry_check
) else (
echo Exiting...
goto end
)
:poetry_check
:: Check if poetry is installed
poetry -V >nul 2>&1
if %ERRORLEVEL% equ 0 (
echo Poetry is installed, removing all environments...
for /f "delims=" %%i in ('poetry env list') do poetry env remove %%i
) else (
echo Poetry is not installed, skipping poetry environment removal.
)
:cleanup
:: Clean up
if exist installed_packages.txt del installed_packages.txt
:: Delete poetry.lock if it exists
if exist poetry.lock del poetry.lock
:end
:: End of script
endlocal