-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyinstall_script.bat
More file actions
70 lines (58 loc) · 1.34 KB
/
Copy pathPyinstall_script.bat
File metadata and controls
70 lines (58 loc) · 1.34 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
@echo off
setlocal enabledelayedexpansion
cd /d "%~dp0"
:: Admin check
net session >nul 2>&1
if %errorlevel% NEQ 0 (
PowerShell -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
exit /B
)
:: Validate
if not exist "main.py" (
echo Error: main.py not found.
pause
exit /B 1
)
:: Version
:version_prompt
set /p "version=Version number (e.g. v2.000): "
if "!version!"=="" goto version_prompt
:: Name
set "appname=WinFunct"
set /p "rename=Rename from 'WinFunct'? (y/n): "
if /i "!rename!"=="y" (
set /p "appname=New name: "
)
:: Zip option
set /p "zip=Create zip archive? (y/n): "
:: Build
echo.
echo Compiling...
pip install pyinstaller >nul 2>&1
pyinstaller --clean --noconfirm --onefile ^
--icon=WinFunct.ico ^
--add-data "WinFunct.ico;." ^
--add-data "UI_themes.json;." ^
--add-data "gui;gui" ^
--add-data "core;core" ^
--add-data "config.py;." ^
--name "!appname!" ^
main.py
if %errorlevel% NEQ 0 (
echo Build failed.
pause
exit /B 1
)
:: Move & rename
move /Y "dist\!appname!.exe" "!appname!_!version!.exe"
:: Zip
if /i "!zip!"=="y" (
powershell -Command "Compress-Archive -Path '.\!appname!_!version!.exe' -DestinationPath '.\!appname!_!version!.zip' -Force"
)
:: Cleanup
rmdir /S /Q dist build 2>nul
del /F /Q *.spec 2>nul
echo.
echo Done: !appname!_!version!.exe
pause
exit /B 0