[PyQt] Finding the app folder under pyqtdeploy

Alexander Zäch alexander.zaech at bytehunter.de
Wed Aug 6 14:33:25 BST 2014


Hi,

scripts using PyInstaller can use

import sys
import os
...
if getattr(sys, 'frozen', False):
    # we are running in a |PyInstaller| bundle
    basedir = sys._MEIPASS
else:
    # we are running in a normal Python environment
    basedir = os.path.dirname(__file__)

(from the PyInstaller manual)

to check if "frozen". sys._MEIPASS contains the path to the folder containing
your script. I prefer using an attribute to sys like PyInstaller or cx_freeze
do. This would make pyqtdeploy a bit more compatible to PyInstaller/cx_freeze.

Alex

> Phil Thompson <phil at riverbankcomputing.com> hat am 5. August 2014 um 22:49
> geschrieben:
> 
> 
> On 05/08/2014 9:05 pm, Florian Bruhin wrote:
> > * Dave Gradwell <davegradwell at yahoo.co.uk> [2014-08-05 20:24:54 +0100]:
> >> Hi,
> >> 
> >> > perhaps a try/except block around "import pyqtdeploy"?]
> >> That's what works for me.
> > 
> > cx_Freeze (and maybe others?) add a frozen attribute to sys, so you
> > can do hasattr(sys, 'frozen').
> > 
> > Maybe that should be added to pyqtdeploy as well, if it isn't already?
> 
> if is_confirmed("and maybe others"):
>     i_will_add_it()
> else:
>     sorry_i_wont()
> 
> Phil
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt


More information about the PyQt mailing list