-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpy_compiler.bat
52 lines (48 loc) · 1.22 KB
/
py_compiler.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
50
51
52
:: Python Compiler (Windows)
@echo off
:: Enable delayed expansion
setlocal enableDelayedExpansion
:: Set console title
title Python Compiler
:: Build info
:Begin
set py_target=example_file
set py_ext=py
set py_gui=no
echo Python file to build: %py_target%
set /p py_target=Do you want to build another file? (Type its name or press ENTER to skip):
set /p py_gui=Do you want to build as GUI App? (Type ^"yes^" or Press ENTER to skip):
:: Check build
if exist "%py_target%.py" (
:: Check build type
if /i "%py_gui%" == "yes" (
set py_ext=pyw
)
:: Check previous build
if exist "%py_target%" (
echo Removing previous build...
rd /s /q "%py_target%"
)
:: Generate temp file
if /i "%py_gui%" == "yes" (
echo Generating temporary file %py_target%.pyw
copy %py_target%.py %py_target%.pyw > nul
)
:: Run build
if exist "%py_target%.!py_ext!" (
echo Building %py_target%.!py_ext!
pyinstaller --clean --onefile %py_target%.!py_ext! --specpath ./%py_target%/spec --distpath ./%py_target%/dist --workpath ./%py_target%/build
)
:: Remove temp file
if /i "%py_gui%" == "yes" (
echo Removing temporary file...
del %py_target%.pyw
)
) else (
:: Try again
echo File "%py_target%.py" not found^^!
pause
cls
goto :Begin
)
pause