[Pythonmac-SIG] py2app and PyQt4

Jeremy Sanders jeremy at jeremysanders.net
Thu Nov 20 21:08:40 CET 2008


Hi - I'm having problems with my PyQt4 application which uses pyuic 
dynamically to load in dialogs.

Firstly py2app doesn't seem to include sip in the output dist, but does 
include PyQt4. Presumably it should work out that PyQt4 is dependent on 
sip. I can fix this with an explicit import sip, but maybe it should 
automatically include sip for PyQt4.

The second problem is that it isn't properly handling this code in PyQt4:

try:
     from xml.etree.cElementTree import parse, SubElement
except ImportError:
     try:
         from cElementTree import parse, SubElement
     except ImportError:
         try:
             from elementtree.ElementTree import parse, SubElement
         except ImportError:
             from PyQt4.elementtree.ElementTree import parse, SubElement

It fails when running the app on the final import, even though it should 
successfully be doing the first xml.etree.cElementTree import from the 
first line. I tried an explicit xml.etree.cElementTree import elsewhere in 
the code but this doesn't fix the problem.

The other issue is in my code. To allow users to run the app without 
installing it, I have this code in the main script:

# Allow veusz to be run even if not installed into PYTHONPATH
try:
     import veusz
except ImportError:
     # load in the veusz module, but change its path to
     # the veusz directory, and insert it into sys.modules
     import __init__ as veusz
     thisdir = os.path.dirname( os.path.abspath(__file__) )
     veusz.__path__ = [thisdir]
     veusz.__name__ = 'veusz'
     sys.modules['veusz'] = veusz

It doesn't process the program properly with this code. If I replace this 
block with just "import veusz" it works. This doesn't make much sense to 
me.

I have another problem with an extension module, but I will save that for 
another email.

Jeremy

-- 
Jeremy Sanders <jeremy at jeremysanders.net>
http://www.jeremysanders.net/                Cambridge, UK
Public Key Server PGP Key ID: E1AAE053


More information about the Pythonmac-SIG mailing list