[PyQt] Determining location of pyqtdeployed app at runtime

Dave Gradwell davegradwell at yahoo.co.uk
Fri Aug 1 19:59:50 BST 2014


Hello,

I would like to determine the location from which my pyqtdeployed application was executed.

I have read this: http://pyqt.sourceforge.net/Docs/pyqtdeploy/pyrcc.html
but this:
    QFileInfo(__file__).absolutePath()
gives me this:
    <frozen>
... when it's pyqtdeployed.  (Although it works fine when it's not frozen.)

This seems to work:
    os.path.dirname(sys.executable)
but is that inadvisable for some reason?  And would I be better off using the advised QFileInfo technique (maybe I have missed something)?

I'm on Mac OS X 10.9, PyQt 5.3.2 and Qt 5.3.1.

With thanks,

Dave.


(N.B.  I like the way pyqtdeploy makes using Qt's Resource system so easy (e.g. by rcc'ing my icons) but in this instance I need to seed an executable into the end-user's filesystem which, although probably not impossible, feels like a bit of a misuse of Resources.  I'd rather just bundle the executable as a file within the .app and copy it from there.)


More information about the PyQt mailing list