From fa87d18c2408d4abdbf9faa209b0cc085b3ff070 Mon Sep 17 00:00:00 2001 From: gentlegiantJGC Date: Thu, 31 Aug 2023 14:51:32 +0100 Subject: [PATCH] Fix linux installer (#58) * Split up pyinstaller hooks Add linux shared object libraries * Added debug output * Fixed glob * Removed print statements * print amulet_editor hidden imports For some reason on linux a singular module is not being included * Added debug output in build process * Added libegl to ubuntu * Reformatted --- .github/workflows/python-build.yml | 4 ++-- .../__pyinstaller/hook-OpenGL.py | 7 +++++++ .../__pyinstaller/hook-PySide6.py | 17 ++++++++++++++++ .../__pyinstaller/hook-amulet_editor.py | 20 +++++++------------ 4 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 src/amulet_editor/__pyinstaller/hook-OpenGL.py create mode 100644 src/amulet_editor/__pyinstaller/hook-PySide6.py diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml index e17d315..0a3de40 100644 --- a/.github/workflows/python-build.yml +++ b/.github/workflows/python-build.yml @@ -47,14 +47,14 @@ jobs: - name: Install Ubuntu dependencies if: matrix.cfg.os == 'ubuntu-latest' run: | - sudo apt-get install ruby-dev build-essential + sudo apt-get install ruby-dev build-essential libegl1-mesa libegl1-mesa-dev sudo gem i fpm -f - name: Create Installer run: | pip install git+https://github.com/Amulet-Team/python-build-tool.git pip install --upgrade --upgrade-strategy eager -e . - pbt freeze + pbt freeze --debug pbt installer - name: Upload Release Asset diff --git a/src/amulet_editor/__pyinstaller/hook-OpenGL.py b/src/amulet_editor/__pyinstaller/hook-OpenGL.py new file mode 100644 index 0000000..30aa51d --- /dev/null +++ b/src/amulet_editor/__pyinstaller/hook-OpenGL.py @@ -0,0 +1,7 @@ +from PyInstaller.utils.hooks import ( + collect_submodules, +) + +hiddenimports = [ + *collect_submodules("OpenGL"), # On my linux install not everything was included. +] diff --git a/src/amulet_editor/__pyinstaller/hook-PySide6.py b/src/amulet_editor/__pyinstaller/hook-PySide6.py new file mode 100644 index 0000000..75cfb8f --- /dev/null +++ b/src/amulet_editor/__pyinstaller/hook-PySide6.py @@ -0,0 +1,17 @@ +import glob +import os +from PyInstaller.utils.hooks import ( + collect_data_files, + collect_submodules, +) + +import PySide6 + +hiddenimports = collect_submodules("PySide6") +binaries = [ + (path, ".") + for path in glob.glob( + os.path.join(glob.escape(PySide6.__path__[0]), "Qt", "lib", "*.so*") + ) +] +datas = collect_data_files("PySide6", includes=["*.pyi", "py.typed"]) diff --git a/src/amulet_editor/__pyinstaller/hook-amulet_editor.py b/src/amulet_editor/__pyinstaller/hook-amulet_editor.py index 80f8315..4462b4c 100644 --- a/src/amulet_editor/__pyinstaller/hook-amulet_editor.py +++ b/src/amulet_editor/__pyinstaller/hook-amulet_editor.py @@ -1,16 +1,10 @@ -try: - from PyInstaller.utils.hooks import ( - collect_data_files, - copy_metadata, - collect_submodules, - ) -except ImportError as e: - raise ImportError( - "This is part of the build pipeline. It cannot be imported at runtime." - ) from e +from PyInstaller.utils.hooks import ( + collect_data_files, + copy_metadata, + collect_submodules, +) datas = [ - *collect_data_files("PySide6", includes=["*.pyi", "py.typed"]), *collect_data_files("amulet_editor", excludes=["**/*.ui", "**/*.c", "**/*.pyx"]), *collect_data_files( "amulet_editor.plugins", @@ -22,6 +16,6 @@ hiddenimports = [ *collect_submodules("amulet_editor", lambda name: name != "amulet_editor.plugins"), - *collect_submodules("PySide6"), - *collect_submodules("OpenGL"), # On my linux install not everything was included. + "PySide6", + "OpenGL", ]