diff --git a/README.md b/README.md index 3252472..ed002fb 100644 --- a/README.md +++ b/README.md @@ -126,12 +126,12 @@ Here's a quick guide on how to freeze Pesterchum, (that is, packaging it with py Ideally, you'll want to create and activate a [virtual environment](https://docs.python.org/3/library/venv.html) before anything else, this is not 100% required though. ### [CX_FREEZE](https://cx-freeze.readthedocs.io/en/latest/index.html) -1. ``pip install cx_freeze`` +1. ``python3 -m pip install cx_freeze`` 2. ``python3 setup.py build`` ### [PYINSTALLER](https://pyinstaller.readthedocs.io/en/stable/) -1. ``pip install pyinstaller`` -2. ``python3 pyinstaller.py`` +1. ``python3 -m pip install pyinstaller`` +2. ``python3 pyinst.py`` ## SMILIES pesterchum what did you do smilie |Text|Smilie| diff --git a/__init__.py b/__init__.py deleted file mode 100644 index 8d1c8b6..0000000 --- a/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/__main__.py b/__main__.py deleted file mode 100644 index 2fee9c7..0000000 --- a/__main__.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python3 -# Tries to run_as_subprocess.py as an absolute and relative import. (for script or module) -import sys - -try: - from .run_as_subprocess import main -except (ImportError, ModuleNotFoundError): - from run_as_subprocess import main - -main(sys.argv) diff --git a/oyoyo/__init__.py b/oyoyo/__init__.py deleted file mode 100644 index 16018de..0000000 --- a/oyoyo/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) 2008 Duncan Fordyce -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -"""A small, simple irc lib for python suitable for bots, clients and anything else. - -For more information and documentation about this package: - http://code.google.com/p/oyoyo/ -""" diff --git a/pnc/__init__.py b/pnc/__init__.py deleted file mode 100644 index 9e4eee4..0000000 --- a/pnc/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# -*- coding=UTF-8; tab-width: 4 -*- - -# These both seem to be worthless because they don't propogate to the modules -# lower down.... -##from __future__ import division -##from __future__ import absolute_import # JUST in case. - -# No __all__ or similar, for now. diff --git a/pnc/dep/__init__.py b/pnc/dep/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pyinstaller.py b/pyinst.py similarity index 84% rename from pyinstaller.py rename to pyinst.py index d4a1577..f1543ce 100644 --- a/pyinstaller.py +++ b/pyinst.py @@ -49,6 +49,8 @@ upx_exclude = [ "qwindows.dll", "Qt6Core.dll", "Qt6Gui.dll", + "Qt5Core.dll", + "Qt5Gui.dll", "vcruntime140.dll", "MSVCP140.dll", "MSVCP140_1.dll", @@ -103,69 +105,134 @@ package_universal_crt = "" onefile = "" windowed = "" upx_dir = "" +crt_path = "" # Command line options 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() -if _ARGUMENTS.clean == True: - delete_builddist = "y" -elif _ARGUMENTS.clean == False: - delete_builddist = "n" +# Python 3.8 doesn't support optional boolean actions +# py3.8 usage is --upx True, py3.9+ usage is --upx/--no-upx +# The values for py3.8 are str, for 3.9+ they're booleans +# This is very cringe 2) and (sys.version_info[1] > 8): + # Python 3.9 and up + 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() + if _ARGUMENTS.clean == True: + delete_builddist = "y" + elif _ARGUMENTS.clean == False: + delete_builddist = "n" -if _ARGUMENTS.upx == True: - upx_enabled = "y" -elif _ARGUMENTS.upx == False: - upx_enabled = "n" + if _ARGUMENTS.upx == True: + upx_enabled = "y" + elif _ARGUMENTS.upx == False: + upx_enabled = "n" -if _ARGUMENTS.crt == True: - package_universal_crt = "y" -elif _ARGUMENTS.crt == False: - package_universal_crt = "n" + if _ARGUMENTS.crt == True: + package_universal_crt = "y" + elif _ARGUMENTS.crt == False: + package_universal_crt = "n" -if _ARGUMENTS.onefile == True: - onefile = "y" -elif _ARGUMENTS.onefile == False: - onefile = "n" + if _ARGUMENTS.onefile == True: + onefile = "y" + elif _ARGUMENTS.onefile == False: + onefile = "n" -if _ARGUMENTS.windowed == True: - windowed = "y" -elif _ARGUMENTS.windowed == False: - windowed = "n" + if _ARGUMENTS.windowed == True: + windowed = "y" + elif _ARGUMENTS.windowed == False: + windowed = "n" +else: + # Python 3.8 and below + parser.add_argument( + "--prompts", + help="Prompt for the options below on run", + action="store", + choices=["True", "False"], + ) + parser.add_argument( + "--onefile", + help="Create a one-file bundled executable.", + action="store", + choices=["True", "False"], + ) + parser.add_argument( + "--upx", + help="Try to compress binaries with UPX.", + action="store", + choices=["True", "False"], + ) + parser.add_argument( + "--crt", + help="Try to bundle Universal CRT with the build", + action="store", + choices=["True", "False"], + ) + parser.add_argument( + "--clean", + help="Remove build+dist directories with shutil before building.", + action="store", + choices=["True", "False"], + ) + parser.add_argument( + "--windowed", + help="Build without console.", + action="store", + choices=["True", "False"], + ) + _ARGUMENTS = parser.parse_args() + if _ARGUMENTS.clean == "True": + delete_builddist = "y" + elif _ARGUMENTS.clean == "False": + delete_builddist = "n" + if _ARGUMENTS.upx == "True": + upx_enabled = "y" + elif _ARGUMENTS.upx == "False": + upx_enabled = "n" + if _ARGUMENTS.crt == "True": + package_universal_crt = "y" + elif _ARGUMENTS.crt == "False": + package_universal_crt = "n" + 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: +if (_ARGUMENTS.prompts != False) and (_ARGUMENTS.prompts != "False"): try: print( "This is a script to make building with Pyinstaller a bit more conventient." @@ -204,7 +271,7 @@ if _ARGUMENTS.prompts != False: 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]: " + "Path to 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. @@ -220,7 +287,7 @@ if _ARGUMENTS.prompts != False: ) else: crt_path = input( - "Extra path: [C:\\Program Files (x86)\\Windows Kits\\10\\Redist\\10.0.19041.0\\ucrt\\DLLs\\x86]: " + "Path to universal CRT: [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. @@ -249,6 +316,29 @@ else: if _ARGUMENTS.upx == None: upx_enabled = "n" if _ARGUMENTS.crt == None: + if is_64bit == True: + 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 = 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) package_universal_crt = "y" if _ARGUMENTS.onefile == None: onefile = "y" @@ -298,7 +388,7 @@ if sys.platform == "win32": run_win32.append("--add-data=%s" % x) if package_universal_crt == "y": - run_win32.append('--paths="%s"' % crt_path) + run_win32.append("--paths=%s" % crt_path) if os.path.exists(crt_path): if is_64bit == False: run_win32.append( diff --git a/run_as_subprocess.py b/run_as_subprocess.py deleted file mode 100644 index 2f79f44..0000000 --- a/run_as_subprocess.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python3 -# Wrapper script to run Pesterchum from an import independently of the current working directory. (useful for wheel) -# Running MainProgram() from an import would be better, but I think it requires making **all** imports relative depending on __main__, -# and probably other stuff too- - -import os -import sys -from subprocess import call - -# print(sys.argv) -def main(argv): - arguments = "" - for x in argv[1:]: - arguments += x + " " - # print(arguments) - - directory_path = os.getcwd() - print("Working directory: " + directory_path) - os.chdir(os.path.dirname(__file__)) - print("Working directory set to: " + directory_path) - print("Running Pesterchum as subprocess, this is not ideal.") - retcode = call("python3 pesterchum.py " + " " + str(arguments), shell=True) - print(retcode) - - -if __name__ == "__main__": - main(sys.argv)