Add command-line options to pyinstaller.py for automated building, finish pyqt5 multimedia sound, fix incorrect arguments in pyinstaller.py+setup.py
This commit is contained in:
parent
a51e4dd69e
commit
fc08a442fa
4 changed files with 162 additions and 83 deletions
|
@ -2321,7 +2321,9 @@ class PesterWindow(MovingWindow):
|
||||||
self.namesound = soundclass("themes/namealarm.wav")
|
self.namesound = soundclass("themes/namealarm.wav")
|
||||||
self.ceasesound = soundclass(self.theme["main/sounds/ceasesound"])
|
self.ceasesound = soundclass(self.theme["main/sounds/ceasesound"])
|
||||||
self.honksound = soundclass("themes/honk.wav")
|
self.honksound = soundclass("themes/honk.wav")
|
||||||
elif "PyQt6.QtMultimedia" in sys.modules:
|
if ("PyQt6.QtMultimedia" in sys.modules) or (
|
||||||
|
"PyQt5.QtMultimedia" in sys.modules
|
||||||
|
):
|
||||||
if soundclass == QtMultimedia.QSoundEffect:
|
if soundclass == QtMultimedia.QSoundEffect:
|
||||||
self.alarm = soundclass()
|
self.alarm = soundclass()
|
||||||
self.memosound = soundclass()
|
self.memosound = soundclass()
|
||||||
|
@ -2367,7 +2369,9 @@ class PesterWindow(MovingWindow):
|
||||||
if "pygame" in sys.modules:
|
if "pygame" in sys.modules:
|
||||||
if self.sound_type == pygame.mixer.Sound:
|
if self.sound_type == pygame.mixer.Sound:
|
||||||
sound.set_volume(vol)
|
sound.set_volume(vol)
|
||||||
if "PyQt6.QtMultimedia" in sys.modules:
|
if ("PyQt6.QtMultimedia" in sys.modules) or (
|
||||||
|
"PyQt5.QtMultimedia" in sys.modules
|
||||||
|
):
|
||||||
if self.sound_type == QtMultimedia.QSoundEffect:
|
if self.sound_type == QtMultimedia.QSoundEffect:
|
||||||
sound.setVolume(vol)
|
sound.setVolume(vol)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|
232
pyinstaller.py
232
pyinstaller.py
|
@ -1,6 +1,8 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
|
import argparse
|
||||||
|
|
||||||
import PyInstaller.__main__
|
import PyInstaller.__main__
|
||||||
|
|
||||||
|
@ -49,7 +51,7 @@ upx_exclude = [
|
||||||
"Qt6Gui.dll",
|
"Qt6Gui.dll",
|
||||||
"vcruntime140.dll",
|
"vcruntime140.dll",
|
||||||
"MSVCP140.dll",
|
"MSVCP140.dll",
|
||||||
"MSVCP140_1.dll" "api-ms-win-core-console-l1-1-0.dll",
|
"MSVCP140_1.dll",
|
||||||
"api-ms-win-core-console-l1-1-0.dll",
|
"api-ms-win-core-console-l1-1-0.dll",
|
||||||
"api-ms-win-core-console-l1-2-0.dll",
|
"api-ms-win-core-console-l1-2-0.dll",
|
||||||
"api-ms-win-core-datetime-l1-1-0.dll",
|
"api-ms-win-core-datetime-l1-1-0.dll",
|
||||||
|
@ -100,90 +102,168 @@ upx_enabled = ""
|
||||||
package_universal_crt = ""
|
package_universal_crt = ""
|
||||||
onefile = ""
|
onefile = ""
|
||||||
windowed = ""
|
windowed = ""
|
||||||
|
upx_dir = ""
|
||||||
|
|
||||||
try:
|
# Command line options
|
||||||
print("This is a script to make building with Pyinstaller a bit more conventient.")
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument(
|
||||||
|
"--prompts",
|
||||||
|
help="Prompt for the options below on run",
|
||||||
|
action=argparse.BooleanOptionalAction,
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--onefile",
|
||||||
|
help="Create a one-file bundled executable.",
|
||||||
|
action=argparse.BooleanOptionalAction,
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--upx",
|
||||||
|
help="Try to compress binaries with UPX.",
|
||||||
|
action=argparse.BooleanOptionalAction,
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--crt",
|
||||||
|
help="Try to bundle Universal CRT with the build",
|
||||||
|
action=argparse.BooleanOptionalAction,
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--clean",
|
||||||
|
help="Remove build+dist directories with shutil before building.",
|
||||||
|
action=argparse.BooleanOptionalAction,
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--windowed",
|
||||||
|
help="Build without console.",
|
||||||
|
action=argparse.BooleanOptionalAction,
|
||||||
|
)
|
||||||
|
_ARGUMENTS = parser.parse_args()
|
||||||
|
|
||||||
while (delete_builddist != "y") and (delete_builddist != "n"):
|
if _ARGUMENTS.clean == True:
|
||||||
delete_builddist = input("Delete build & dist folders? (Y/N): ").lower()
|
delete_builddist = "y"
|
||||||
if delete_builddist == "y":
|
elif _ARGUMENTS.clean == False:
|
||||||
try:
|
delete_builddist = "n"
|
||||||
shutil.rmtree("dist")
|
|
||||||
except FileNotFoundError as e:
|
|
||||||
print(e)
|
|
||||||
try:
|
|
||||||
shutil.rmtree("build")
|
|
||||||
except FileNotFoundError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
while (upx_enabled != "y") and (upx_enabled != "n"):
|
if _ARGUMENTS.upx == True:
|
||||||
upx_enabled = input("Enable UPX? (Y/N): ").lower()
|
upx_enabled = "y"
|
||||||
if upx_enabled == "y":
|
elif _ARGUMENTS.upx == False:
|
||||||
print("If upx is on your path you don't need to include anything here.")
|
upx_enabled = "n"
|
||||||
if is_64bit == True:
|
|
||||||
upx_dir = input("UPX directory [D:\\upx-3.96-win64]: ")
|
|
||||||
if upx_dir == "":
|
|
||||||
upx_dir = "D:\\upx-3.96-win64" # Default dir for me :)
|
|
||||||
else:
|
|
||||||
upx_dir = input("UPX directory [D:\\upx-3.96-win32]: ")
|
|
||||||
if upx_dir == "":
|
|
||||||
upx_dir = "D:\\upx-3.96-win32" # Default dir for me :)
|
|
||||||
print("upx_dir = " + upx_dir)
|
|
||||||
elif upx_enabled == "n":
|
|
||||||
upx_dir = ""
|
|
||||||
|
|
||||||
while (windowed != "y") and (windowed != "n"):
|
if _ARGUMENTS.crt == True:
|
||||||
windowed = input("Build with '--windowed'? (Y/N): ").lower()
|
package_universal_crt = "y"
|
||||||
|
elif _ARGUMENTS.crt == False:
|
||||||
|
package_universal_crt = "n"
|
||||||
|
|
||||||
if sys.platform == "win32":
|
if _ARGUMENTS.onefile == True:
|
||||||
|
onefile = "y"
|
||||||
|
elif _ARGUMENTS.onefile == False:
|
||||||
|
onefile = "n"
|
||||||
|
|
||||||
|
if _ARGUMENTS.windowed == True:
|
||||||
|
windowed = "y"
|
||||||
|
elif _ARGUMENTS.windowed == False:
|
||||||
|
windowed = "n"
|
||||||
|
|
||||||
|
parser.print_usage()
|
||||||
|
|
||||||
|
if _ARGUMENTS.prompts != False:
|
||||||
|
try:
|
||||||
print(
|
print(
|
||||||
"(https://pyinstaller.readthedocs.io/en/stable/usage.html?highlight=sdk#windows)"
|
"This is a script to make building with Pyinstaller a bit more conventient."
|
||||||
)
|
)
|
||||||
while (package_universal_crt != "y") and (package_universal_crt != "n"):
|
|
||||||
package_universal_crt = input(
|
while (delete_builddist != "y") and (delete_builddist != "n"):
|
||||||
"Try to include universal CRT? (Y/N): "
|
delete_builddist = input("Delete build & dist folders? (Y/N): ").lower()
|
||||||
).lower()
|
|
||||||
if package_universal_crt == "y":
|
while (upx_enabled != "y") and (upx_enabled != "n"):
|
||||||
|
upx_enabled = input("Enable UPX? (Y/N): ").lower()
|
||||||
|
if upx_enabled == "y":
|
||||||
|
print("If upx is on your path you don't need to include anything here.")
|
||||||
if is_64bit == True:
|
if is_64bit == True:
|
||||||
crt_path = input(
|
upx_dir = input("UPX directory [D:\\upx-3.96-win64]: ")
|
||||||
"Universal CRT: [C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x64]: "
|
if upx_dir == "":
|
||||||
)
|
upx_dir = "D:\\upx-3.96-win64" # Default dir for me :)
|
||||||
if crt_path == "":
|
|
||||||
# crt_path = "C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x64" # Default directory.
|
|
||||||
crt_path = os.path.join(
|
|
||||||
"C:%s" % os.sep,
|
|
||||||
"Program Files (x86)",
|
|
||||||
"Windows Kits",
|
|
||||||
"10",
|
|
||||||
"10.0.19041.0",
|
|
||||||
"ucrt",
|
|
||||||
"DLLs",
|
|
||||||
"x64",
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
crt_path = input(
|
upx_dir = input("UPX directory [D:\\upx-3.96-win32]: ")
|
||||||
"Extra path: [C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x86]: "
|
if upx_dir == "":
|
||||||
)
|
upx_dir = "D:\\upx-3.96-win32" # Default dir for me :)
|
||||||
if crt_path == "":
|
print("upx_dir = " + upx_dir)
|
||||||
# crt_path = "C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x86" # Default directory.
|
elif upx_enabled == "n":
|
||||||
crt_path = os.path.join(
|
upx_dir = ""
|
||||||
"C:%s" % os.sep,
|
|
||||||
"Program Files (x86)",
|
while (windowed != "y") and (windowed != "n"):
|
||||||
"Windows Kits",
|
windowed = input("Build with '--windowed'? (Y/N): ").lower()
|
||||||
"10",
|
|
||||||
"10.0.19041.0",
|
if sys.platform == "win32":
|
||||||
"ucrt",
|
print(
|
||||||
"DLLs",
|
"(https://pyinstaller.readthedocs.io/en/stable/usage.html?highlight=sdk#windows)"
|
||||||
"x86",
|
)
|
||||||
|
while (package_universal_crt != "y") and (package_universal_crt != "n"):
|
||||||
|
package_universal_crt = input(
|
||||||
|
"Try to include universal CRT? (Y/N): "
|
||||||
|
).lower()
|
||||||
|
if package_universal_crt == "y":
|
||||||
|
if is_64bit == True:
|
||||||
|
crt_path = input(
|
||||||
|
"Universal CRT: [C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x64]: "
|
||||||
)
|
)
|
||||||
print("crt_path = " + crt_path)
|
if crt_path == "":
|
||||||
|
# crt_path = "C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x64" # Default directory.
|
||||||
|
crt_path = os.path.join(
|
||||||
|
"C:%s" % os.sep,
|
||||||
|
"Program Files (x86)",
|
||||||
|
"Windows Kits",
|
||||||
|
"10",
|
||||||
|
"10.0.19041.0",
|
||||||
|
"ucrt",
|
||||||
|
"DLLs",
|
||||||
|
"x64",
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
crt_path = input(
|
||||||
|
"Extra path: [C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x86]: "
|
||||||
|
)
|
||||||
|
if crt_path == "":
|
||||||
|
# crt_path = "C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x86" # Default directory.
|
||||||
|
crt_path = os.path.join(
|
||||||
|
"C:%s" % os.sep,
|
||||||
|
"Program Files (x86)",
|
||||||
|
"Windows Kits",
|
||||||
|
"10",
|
||||||
|
"10.0.19041.0",
|
||||||
|
"ucrt",
|
||||||
|
"DLLs",
|
||||||
|
"x86",
|
||||||
|
)
|
||||||
|
print("crt_path = " + crt_path)
|
||||||
|
|
||||||
if (sys.platform == "win32") or (sys.platform == "linux"):
|
if (sys.platform == "win32") or (sys.platform == "linux"):
|
||||||
while (onefile != "y") and (onefile != "n"):
|
while (onefile != "y") and (onefile != "n"):
|
||||||
onefile = input("Build with '--onefile'? (Y/N): ").lower()
|
onefile = input("Build with '--onefile'? (Y/N): ").lower()
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
sys.exit("KeyboardInterrupt")
|
sys.exit("KeyboardInterrupt")
|
||||||
|
else:
|
||||||
|
# no-prompt was given
|
||||||
|
if _ARGUMENTS.clean == None:
|
||||||
|
delete_builddist = "n"
|
||||||
|
if _ARGUMENTS.upx == None:
|
||||||
|
upx_enabled = "n"
|
||||||
|
if _ARGUMENTS.crt == None:
|
||||||
|
package_universal_crt = "y"
|
||||||
|
if _ARGUMENTS.onefile == None:
|
||||||
|
onefile = "y"
|
||||||
|
if _ARGUMENTS.windowed == None:
|
||||||
|
windowed = "y"
|
||||||
|
|
||||||
|
if delete_builddist == "y":
|
||||||
|
try:
|
||||||
|
shutil.rmtree("dist")
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
print(e)
|
||||||
|
try:
|
||||||
|
shutil.rmtree("build")
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
# Windows
|
# Windows
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
|
@ -221,9 +301,6 @@ if sys.platform == "win32":
|
||||||
run_win32.append('--paths="%s"' % crt_path)
|
run_win32.append('--paths="%s"' % crt_path)
|
||||||
if os.path.exists(crt_path):
|
if os.path.exists(crt_path):
|
||||||
if is_64bit == False:
|
if is_64bit == False:
|
||||||
run_win32.append(
|
|
||||||
"--add-binary=%s\\api-ms-win-core-console-l1-1-0.dll;." % crt_path
|
|
||||||
)
|
|
||||||
run_win32.append(
|
run_win32.append(
|
||||||
"--add-binary=%s\\api-ms-win-core-console-l1-1-0.dll;." % crt_path
|
"--add-binary=%s\\api-ms-win-core-console-l1-1-0.dll;." % crt_path
|
||||||
)
|
)
|
||||||
|
@ -627,7 +704,8 @@ else:
|
||||||
|
|
||||||
run_generic = [
|
run_generic = [
|
||||||
"pesterchum.py",
|
"pesterchum.py",
|
||||||
"--name=Pesterchum" "--clean", # Clear cache
|
"--name=Pesterchum",
|
||||||
|
"--clean", # Clear cache
|
||||||
]
|
]
|
||||||
|
|
||||||
if upx_enabled == "y":
|
if upx_enabled == "y":
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -69,9 +69,6 @@ build_exe_options = {
|
||||||
"PyQt6.QtAssistant",
|
"PyQt6.QtAssistant",
|
||||||
"PyQt6.QtDesigner",
|
"PyQt6.QtDesigner",
|
||||||
"PyQt6.QAxContainer",
|
"PyQt6.QAxContainer",
|
||||||
"pygame.docs" # Hopefully we can just not have pygame at all at some point =3
|
|
||||||
# (when QtMultimedia stops relying on local codecs </3)
|
|
||||||
"pygame.examples",
|
|
||||||
"pygame.tests",
|
"pygame.tests",
|
||||||
"pydoc_data",
|
"pydoc_data",
|
||||||
],
|
],
|
||||||
|
|
2
toast.py
2
toast.py
|
@ -478,4 +478,4 @@ class PesterToastMachine(ToastMachine, QtCore.QObject):
|
||||||
# ~ self.connect(self.timer, QtCore.SIGNAL('timeout()'),
|
# ~ self.connect(self.timer, QtCore.SIGNAL('timeout()'),
|
||||||
# ~ self, QtCore.SLOT('showNext()'))
|
# ~ self, QtCore.SLOT('showNext()'))
|
||||||
# ~ if self.on:
|
# ~ if self.on:
|
||||||
# ~ self.timer.start()
|
# ~ self.timer.start()
|
||||||
|
|
Loading…
Reference in a new issue