Image files not included in pysidedeploy build
-
I am building an application that relies on some images. I am packaging the application with the
pysidedeploytool. In my code I am actively changing the root application path to adjust for whether I am running locally or in the deployed application. However I am noticing that in my builds theMacOSfolder in the .appContentsfolder does not contain any of my .png files.For example:
if getattr(sys, "frozen", False): application_path = sys._MEIPASS else: application_path = os.path.dirname(os.path.abspath(__file__)) icon_path = os.path.join(application_path, "icons/1.png") if not os.path.exists(icon_path): print(f"Warning: Icon file not found at {icon_path}")yields a
Warning: Icon file not found at /path/to/build/myApp.app/Contents/MacOS/icons/ooo.pngI have attempted adding the image paths to my pyproject file:
{ "files": [ ... "icons/1.png", "icons/2.png", ... ] }And also to my pysidedeploy.spec
[files] include = icons/1.png, icons/2.png,However still there are no png artifacts located anywhere in my build directory. How can this be done?
-
For the
.qrcapproach to work, which is what we recommend, to do the following:If you have
icons/in the root of your project, then add to your.qrcfile needs to have entries like:<file>icons/1.png</file>, and then when you generate the.pyfile out of it, you import it in the file you want to use, and refer to the files like:/icons/1.png.More information in https://doc.qt.io/qtforpython-6/tutorials/basictutorial/qrcfiles.html#tutorial-qrcfiles
With that,
pyside6-projectwill pick them automatically.The
<name>.pyprojectfile is only a construct for QtCreator to open projects, and it's not related topyside6-deploy