import os import sys import shutil import PyInstaller.__main__ if sys.version_info < (3, 0, 0): sys.exit("Python versions lower than 3 are not supported.") elif (sys.version_info >= (3, 9, 0)) & (sys.platform == 'win32'): print("WARNING!!!! Building with python 3.9 will make your builds not run on windows 7 and previous versions.") def is_64bit() -> bool: return sys.maxsize > 2**32 is_64bit = is_64bit() try: print("Pyinstaller script to make everything a bit more conventient, just being able to run \"pyinstaller\" \ is a lot more useable than having to include all command line arguments every time.\n\ Some of the include files are specific to my instalation, so you might have to edit the file if you run into issues \:\(") delete_builddist = input("Delete build & dist folders? (Y/N): ") if delete_builddist.lower() == "y": try: shutil.rmtree('dist') except FileNotFoundError as e: print(e) try: shutil.rmtree('build') except FileNotFoundError as e: print(e) print("UPX can decently reduce filesize but builds might get flagged by anti-viruses more often. (+ it sometimes breaks QT's DLLs)") if input("Enable UPX? [N]: ").lower() == 'y': upx_enabled = True else: upx_enabled = False if upx_enabled == True: print("If upx is on your path you don't need to include anything here.") 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) else: upx_dir = '' if sys.platform == 'win32': print("\nUniversal CRT needs to be included if you don't want to run into compatibility issues when building on Windows 10. ( https://pyinstaller.readthedocs.io/en/stable/usage.html?highlight=sdk#windows )") if is_64bit == True: crt_path = input("Universal CRT: [C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x64]: ") if crt_path == '': crt_path = "C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x64" # Default directory. 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. print("crt_path = " + crt_path) except KeyboardInterrupt: sys.exit("KeyboardInterrupt") exclude_modules = ['tkinter', 'collections.sys', 'collections._sre', 'collections._json', 'collections._locale', 'collections._struct', 'collections.array', 'collections._weakref', 'PyQt5.QtMultimedia', 'PyQt5.QtDBus', 'PyQt5.QtDeclarative', 'PyQt5.QtHelp', 'PyQt5.QtNetwork', 'PyQt5.QtSql', 'PyQt5.QtSvg', 'PyQt5.QtTest', 'PyQt5.QtWebKit', 'PyQt5.QtXml', 'PyQt5.QtXmlPatterns', 'PyQt5.phonon', 'PyQt5.QtAssistant', 'PyQt5.QtDesigner', 'PyQt5.QAxContainer', 'asyncio', # for now . . . 'email', # ?? :? 'xml', 'pygame.docs' # Hopefully we can just not have pygame at all at some point =3 # (when QtMultimedia stops relying on local codecs