On 3 May, 2011, at 2:07, Brendan Simon (eTRIX) wrote:

> 
> 
> On 3/05/11 6:18 AM, Ronald Oussoren wrote:
>>> I get the following error when trying to run my app when built with py2app 
>>> and python 2.7.
>>> 
>>>   File "crcmod/__init__.pyc", line 7, in <module>
>>> ImportError: No module named predefined
>>> 
>>> The app works fine when built with Python 2.5 or Python 2.6.
>>> 
>>> It seems the folks in py2exe land are having the same issue.
>>> http://thread.gmane.org/gmane.comp.python.py2exe/4301
>>> http://thread.gmane.org/gmane.comp.python.py2exe/4302
>>> 
>>> Any ideas what would be causing this and how it can be 
>>> fixed/solved/worked-around ??
>> 
>> The crcmod package contains a module named crcmod. My guess is that both 
>> py2app and py2exe get confused by this and try to fetch 'crcmod.predefined' 
>> from the nested module instead of the toplevel package.  This basicly means 
>> that both py2*s have a bug in their emulation of the __import__ code.  
>> 
>> I'll see if I can create a testcase for this for the modulegraph package, it 
>> should then be fairly easy to actually fix the issue. As this is only a 
>> problem with python2.7 this may end up being a bug in the stdlib though.
>> 
>> As a workaround try adding includes for crcmod.predefined, or even the 
>> entire crcmod package (setup(..., package=['crcmod'], ...))
> 
> Yep.  Forcing inclusion of the module in setup does resolve the issue.  Here 
> is the snippet of my setup file that worked for me :)
> 
> Hopefully py2app can be fixed so this is not necessary, but at least I have a 
> workaround now.

I think I can fix this in modulegraph, I'm not quite sure why it works in 2.6 
but not in 2.7 though. Are you using the same version of crcmod in both cases?

My current impresssion of what's going on here: crcmod.__init__ contains:

try:
    from crcmod.crcmod import *
    import crcmod.predefined
except ImportError:
    # Make this backward compatible
    from crcmod import *
    import predefined

A test with a simular package structure fails on both 2.6 and 2.7, but works 
with 3.2. Modulegraph fails because it creates a MissingModule node for 
crcmod.predefined, which seems to indicate a bug in how we process imports in a 
package as it should have created a MissingModule node for 
crcmod.crcmod.predefined for the second import statement and then a real node 
for the last one. 

Ronald

> 
> Thanks Ronald !!
> 
> PACKAGES = [ 'crcmod', ]
> 
> OPTIONS = {
>             'argv_emulation' : True,
>             'iconfile' : 'images/myapp.icns',
>             'plist' : Plist,
>             'packages' : PACKAGES,
>            }
> 
> setup(
>     app = APP,
>     data_files = DATA_FILES,
>     options = { 'py2app' : OPTIONS },
>     setup_requires=['py2app'],
> )
> 
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
> unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

Reply via email to