Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
PyQt5 + Qt 5.6 proper way to bundle for site-packages redistribution
Long story short: I'm attempting to get Blender 2.7 and PyQt working together. I've got Qt 5.6.0 build and installed to a dev folder (both dynamic and static). PyQt builds fine, but in order to get the build script to generate loadable Python modules I had to build both Qt and PyQt as dynamic. (If you build Qt static, PyQt says you have to build it static, which drops a bunch of regular libraries into your site packages-- how is that useful?) I'm on a Mac, so I installed the matching Python version using homebrew and made all this happen inside a virtual environment.
So far, so good.
Now, what I want to happen is this: I want to be able to create a single folder with the Python modules and any and all other linked libraries all together in one spot-- no frame works, no hidden things anywhere else. There are two issues I'm dealing with in making this happen:
- The platform plugins don't seem to want to load. I modified the libraryPath with a path to where they are using QApplication.addLibraryPath() before creating the instance (just testing from the command line at the moment) and I got this message:
This application failed to start because it could not find or load the Qt platform plugin "cocoa" in "". Available platform plugins are: cocoa, minimal, offscreen.
... which... what? So it finds them but can't load?
- I want to built Qt static but PyQt as dynamic libraries for the obvious reason of loading in Python. How can this be accomplished through the regular config? Do I have to go in and patch things to make this happen?
Any and all help would be very much appreciated. And please: I'm not interested in solutions that don't do what I've asked above. I don't want to package the Frameworks in with Blender and redistribute the whole app. I don't want to set environment variables. I want to make a single folder that can be added to a site-packages folder inside either the console Python or the Blender Python install and just have it work out of the box. Using the deploy scripts will not work because this is not an application, but something intended to be loaded by (possibly) multiple other applications. What I'm asking should be possible.
Thanks in advance-- been googling around on this for three days and apart from modifying the library path, I don't feel like I'm any closer to even getting a window open from the console.
Here's my Qt build settings:
./configure -prefix $PWD/../5.6.0/ -confirm-license -opensource -release -nomake examples -nomake tests -shared
../venv/bin/python3 configure.py --confirm-license --no-designer-plugin --no-qml-plugin --qmake=../5.6.0/bin/qmake --sip=../venv/bin/sip
SIP and ICU are built and seem to be working.
Hi and welcome to devnet,
You should take a look a macdeployqt it order to help you deploy your application.
I'm not deploying in the standard manner, so the deploy scripts don't help. Near as I can tell the best thing for me to do is to copy the shared libs out of the frameworks and into the site-packages folder for PyQt5, then use install_name_tool to switch everything rpath to executable_path, then provide a bootstrapper that modifies the QApplication library path for users.
Again, in this situation I do not control the app bundle and can't stick things in there. This folder has to live on its own. Am I misunderstanding that the macdeployqt script is really intended to wrap up an application, and not a plugin for another application?
I eventually got the PyQt build working and I can launch a window now. I'd still like to know how to build a usable PyQt with static Qt libs, if you know of any tricks.
AFAIK, macdeployqt is targeted at building a plugin. It's likely tailored towards application bundles but I don't have a definitive answer for that.
I haven't build PyQt with a static Qt at all, only with shared builds. Also note that there are licensing constraints that comes with a static build of Qt.
@SGaist Yeah Since both are LGPL and the static link of Qt is just to build the PyQt shared libs, which will then be loaded from within Python and not directly themselves linked statically, I think I should be in the clear WRT licensing. (If there are any lawyers around who think differently, please educate me.^_^)
I'll have a look again at the mac deploy script. Maybe in there is something I can use for the repathing I'll likely need to do.
No they are not, PyQt only has two licenses: GPLv3 and commercial.
For more information, see their License FAQ
You still need to abide by the license rules regarding your static Qt build. The fact that it's "indirectly loaded" doesn't play any role here. Your module uses PyQt which use Qt.