How do I correctly package PySide6 using cxfreeze?

Viewed 453

I have written a fairly simple GUI application using Python 3.8.0 and PySide6 and I would like to package it for distribution. Based on the table here, I chose cxfreeze as it's compatiable with Qt6 and with Windows/Linux/Mac.

My application in running with a pyenv environment on my development machine, if that makes a difference. The machine is running Debian Bullseye.

I ran the cxfreeze-quickstart wizard in order to create the setup.py script. The output from the script is here (apologies for pastebin link, the text is too long for stackoverflow)

When I run the created executable (build/build/exe.linux-x86_64-3.8/sne), I get the following error:

Traceback (most recent call last):
  File "/home/james/.pyenv/versions/3.8.0/lib/python3.8/site-packages/cx_Freeze/initscripts/__startup__.py", line 104, in run
    module_init.run(name + "__main__")
  File "/home/james/.pyenv/versions/3.8.0/lib/python3.8/site-packages/cx_Freeze/initscripts/Console.py", line 15, in run
    exec(code, module_main.__dict__)
  File "app.py", line 7, in <module>
ImportError: libpyside6.abi3.so.6.1: cannot open shared object file: No such file or directory

The libpyside6.abi3.so.6.1 file is in the build/exe.linux-x86_64-3.8/lib/PySide6 directory.

I added a line to print the contents of sys.path when the application runs:

['/home/james/code/cave-escape/simple-nano-ethernet/SNEGui/build/exe.linux-x86_64-3.8/lib/library.zip', '/home/james/code/cave-escape/simple-nano-ethernet/SNEGui/build/exe.linux-x86_64-3.8/lib']

The lib/PySide6 directory is not in the path, but I believe this is not the issue as the PySide6 package is present in lib.

If I run ldd against libpyside6.abi3.so.6.1, all the dependencies have filepath listed against them except for one:

libshiboken6.abi3.so.6.1 => not found

This file is present in build/exe.linux-x86_64-3.8/lib/shiboken6 directory.

I am guessing I need to make a manual edit to the setup.py script to fix this, or perhaps edit the sys.path at application startup, but I'm not sure exactly what to do in either case.

EDIT: contents of setup.py (autogenerated, unaltered):

from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need
# fine tuning.
build_options = {'packages': [], 'excludes': []}

import sys
base = 'Win32GUI' if sys.platform=='win32' else None

executables = [
    Executable('app.py', base=base, target_name = 'sne')
]

setup(name='Simple Nano Ethernet GUI',
      version = '1.0',
      description = 'An interface to configure the simple nano ethernet board',
      options = {'build_exe': build_options},
      executables = executables)
0 Answers
Related