Repository navigation
Expand file tree
/
Copy pathSetup.bat
More file actions
127 lines (113 loc) · 4.4 KB
/
Copy pathSetup.bat
File metadata and controls
127 lines (113 loc) · 4.4 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
@echo off
setlocal enabledelayedexpansion
title MUG - setup
cd /d "%~dp0"
echo.
echo MUG // recoder
echo Preparing MUG for this computer.
echo -------------------------------------------------------
echo.
REM 1. Find Python, installing it first if this machine has none
set "PYEXE="
py -3 -c "import sys;raise SystemExit(0 if sys.version_info>=(3,9) else 1)" >nul 2>&1
if not errorlevel 1 (
for /f "delims=" %%P in ('py -3 -c "import sys;print(sys.executable)" 2^>nul') do set "PYEXE=%%P"
)
if not defined PYEXE (
python -c "import sys;raise SystemExit(0 if sys.version_info>=(3,9) else 1)" >nul 2>&1
if not errorlevel 1 (
for /f "delims=" %%P in ('python -c "import sys;print(sys.executable)" 2^>nul') do set "PYEXE=%%P"
)
)
if defined PYEXE (
echo !PYEXE! | find /i "WindowsApps" >nul && set "PYEXE="
)
if not defined PYEXE (
echo [1/4] Python was not found. Installing it now...
where winget >nul 2>&1
if errorlevel 1 (
echo.
echo The Windows Package Manager is missing.
echo Install "App Installer" from the Microsoft Store, then run this again.
echo.
pause
exit /b 1
)
winget install -e --id Python.Python.3.12 --scope user --accept-source-agreements --accept-package-agreements
echo.
echo Looking for the new installation...
for /d %%D in ("%LOCALAPPDATA%\Programs\Python\Python3*") do (
if exist "%%D\python.exe" set "PYEXE=%%D\python.exe"
)
if not defined PYEXE (
if exist "%LOCALAPPDATA%\Microsoft\WinGet\Links\python.exe" set "PYEXE=%LOCALAPPDATA%\Microsoft\WinGet\Links\python.exe"
)
if not defined PYEXE (
echo.
echo Python was installed but this window cannot see it yet.
echo Close this window, open the folder again, and run Setup once more.
echo.
pause
exit /b 1
)
) else (
echo [1/4] Python found.
)
echo !PYEXE!
echo.
REM 2. Make sure ffmpeg is present
set "HAVEFF="
where ffmpeg >nul 2>&1 && set "HAVEFF=1"
if exist "%LOCALAPPDATA%\Microsoft\WinGet\Links\ffmpeg.exe" set "HAVEFF=1"
if not defined HAVEFF (
echo [2/4] ffmpeg was not found. Installing it now...
winget install -e --id Gyan.FFmpeg --accept-source-agreements --accept-package-agreements
) else (
echo [2/4] ffmpeg found.
)
echo.
REM 3. Create MUG's private Python environment
echo [3/4] Preparing the application environment...
if not exist "%~dp0runtime\Scripts\python.exe" (
"!PYEXE!" -m venv "%~dp0runtime"
if errorlevel 1 (
echo.
echo Could not create the application environment.
pause
exit /b 1
)
)
"%~dp0runtime\Scripts\python.exe" -m pip install --upgrade pip --quiet
"%~dp0runtime\Scripts\python.exe" -m pip install PySide6 --quiet
if errorlevel 1 (
echo.
echo Could not download the interface library. Check the internet connection
echo and run this file again.
pause
exit /b 1
)
echo done.
echo.
REM 4. Launcher and desktop shortcut
echo [4/4] Creating the launcher and a desktop shortcut...
> "%~dp0MUG.bat" echo @echo off
>>"%~dp0MUG.bat" echo start "" "%%~dp0runtime\Scripts\pythonw.exe" "%%~dp0MUG.py"
> "%TEMP%\mug_shortcut.ps1" echo $desktop = [Environment]::GetFolderPath('Desktop')
>>"%TEMP%\mug_shortcut.ps1" echo $shell = New-Object -ComObject WScript.Shell
>>"%TEMP%\mug_shortcut.ps1" echo $link = $shell.CreateShortcut((Join-Path $desktop 'MUG.lnk'))
>>"%TEMP%\mug_shortcut.ps1" echo $link.TargetPath = '%~dp0runtime\Scripts\pythonw.exe'
>>"%TEMP%\mug_shortcut.ps1" echo $link.Arguments = '"%~dp0MUG.py"'
>>"%TEMP%\mug_shortcut.ps1" echo $link.WorkingDirectory = '%~dp0'
>>"%TEMP%\mug_shortcut.ps1" echo $link.Description = 'MUG // recoder - video codec converter'
>>"%TEMP%\mug_shortcut.ps1" echo $link.IconLocation = '%~dp0runtime\Scripts\pythonw.exe,0'
>>"%TEMP%\mug_shortcut.ps1" echo $link.Save()
powershell -NoProfile -ExecutionPolicy Bypass -File "%TEMP%\mug_shortcut.ps1" >nul 2>&1
del "%TEMP%\mug_shortcut.ps1" >nul 2>&1
echo done.
echo.
echo -------------------------------------------------------
echo Ready. There is now a MUG shortcut on your desktop.
echo You can also start it with MUG.bat in this folder.
echo -------------------------------------------------------
echo.
pause