Image files not included in pysidedeploy build
-
I am building an application that relies on some images. I am packaging the application with the
pysidedeploy
tool. 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 theMacOS
folder in the .appContents
folder 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.png
I 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
.qrc
approach 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.qrc
file needs to have entries like:<file>icons/1.png</file>
, and then when you generate the.py
file 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-project
will pick them automatically.The
<name>.pyproject
file is only a construct for QtCreator to open projects, and it's not related topyside6-deploy