[PyQt] fail to load libqcocoa.dylib on sandboxed OSX PyQt app
Phil Thompson
phil at riverbankcomputing.com
Fri Jun 6 10:19:25 BST 2014
On 05/06/2014 4:26 pm, lloyd konneker wrote:
> I have built a sandboxed PyQt app on OSX (pyqtdeploy, convert to Xcode
> proj, macdeployqt inside Xcode, ...Product>Archive). That all seems to
> work: the bundle is complete and includes an appropriate qt.conf (and
> is sandboxed and codesigned.)
>
> But I think I also need to have a preamble to my app to
> addLibraryPath() to plugins:
>
> def _appBundlePluginPath():
> '''
> path to plugin component of OSX app's bundle
> or None
> '''
> # use Python os, class method QCoreApplication.applicationDirPath()
> cannot be used until QCoreApplication is instantiated?
> appPath = _appBundlePath()
> # Typically "APP_DIR/Contents/MacOS" on OSX.
> # else is path that usually does not have a Plugins sub dir
> appDir = QDir(appPath)
> if not appDir.cdUp():
> logAlert("Failed cdUp from appDir")
> # assert like ../Contents
> if appDir.cd("PlugIns"):
> result = appDir.absolutePath()
> # assert like ../Contents/PlugIns
> else:
> result = None
> return result
>
> def _appBundlePath():
> '''
> This returns a strange path for sandboxed apps '.../:/...'.
> I don't understand what the colon means
> '''
> return os.path.dirname(os.path.abspath( __file__ ))
>
> But the cdUp() fails because of the colon in the strange path?
The colon is what Qt uses to identify a file in a resource file.
Obviously the Python stdlib doesn't understand those so use QFile and
QDir when computing locations relative to __file__. However, in this
case, I don't see how __file__ would be related to the bundle path -
applicationDirPath() seems more sensible.
> Should I give up and link libqcocoa statically (I am loathe to build
> Qt on OSX) or is there some way to get a proper path to plugins in
> the sandbox?
>
> (Or is addLibraryPath() even necessary, does Qt read qt.conf first and
> is it working on sandboxed apps?)
>
> (Is the strange path related to chroot, can I somehow fabricate an
> absolute path to the plugins directory, and will sandboxing let Qt
> access it?)
Phil
More information about the PyQt
mailing list