-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonInstallation.bat
More file actions
72 lines (58 loc) · 2.19 KB
/
pythonInstallation.bat
File metadata and controls
72 lines (58 loc) · 2.19 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
@echo off
set "PYTHON_STUFF_DIR=%~dp0vision\python"
set "INSTALLATION_DIR=%PYTHON_STUFF_DIR%\installation"
:: Specify the version of Python we want to download
set "PYTHON_VERSION_SHORT=3.10"
set "PYTHON_VERSION=%PYTHON_VERSION_SHORT%.0"
set "PYTHON_URL=https://www.python.org/ftp/python/%PYTHON_VERSION%/python-%PYTHON_VERSION%-amd64.exe"
set "EXE_NAME=python-%PYTHON_VERSION%-amd64.exe"
set "VIRTUAL_ENV_NAME=mp_env"
:: Check if the system is 64-bit
if NOT "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
echo Cannot run this application on 32-bit OS. Sorry.
pause
exit /b 1
)
:: Create installation directory if it doesn't exist
if not exist "%INSTALLATION_DIR%" mkdir "%INSTALLATION_DIR%"
:: Download Python installer if the file doesn't exist
if not exist "%INSTALLATION_DIR%\%EXE_NAME%" (
echo Downloading Python %PYTHON_VERSION%.
powershell -Command "Invoke-WebRequest -Uri %PYTHON_URL% -OutFile %INSTALLATION_DIR%\%EXE_NAME%"
)
:: Check if the installer has been downloaded
if not exist "%INSTALLATION_DIR%\%EXE_NAME%" (
echo Error downloading file. Check your internet connection.
pause
exit /b 1
)
:: Run the .exe installer
echo Starting Python installation.
"%INSTALLATION_DIR%\%EXE_NAME%"
:: Check if the installation was successful
if %errorlevel% neq 0 (
echo Error during installation. Check your installation file.
pause
exit /b 1
)
:: Confirmation of successful installation
echo Python %PYTHON_VERSION% has been installed successfully!
:: Create virtual environment for the application
echo Creating virtual environment for application.
py -%PYTHON_VERSION_SHORT% -m venv %PYTHON_STUFF_DIR%\%VIRTUAL_ENV_NAME%
:: Check if virtual environment was created successfully
if not exist "%PYTHON_STUFF_DIR%\%VIRTUAL_ENV_NAME%\Scripts\python.exe" (
echo Virtual environment creation failed.
pause
exit /b 1
)
:: Install mediapipe
echo Installing mediapipe.
"%PYTHON_STUFF_DIR%\%VIRTUAL_ENV_NAME%\Scripts\python.exe" -m pip install mediapipe
:: Clean up the installer and installation directory
echo Cleaning up.
del "%INSTALLATION_DIR%\%EXE_NAME%"
rmdir /s /q "%INSTALLATION_DIR%"
echo Virtual environment for PolyTheremin is ready to use!
echo Happy Theremining :)
pause