[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] py2exe



Guillaume (et al),

I tried putting 

from pygame import movie
from pygame import movieext
from pygame import overlay

into my script and still got the same error message about missing
modules.  I'm not sure how that could be, it seems like it would have
to grab them.  It did grab pygame (or at least there is a 'pygame'
folder in my library.zip anyway... but of course no
movie/movieext/overlay files w/in it).

I probably shouldnt be worrying about it as long as my resulting .exe
runs fine.  I suppose it just worries me that I might, at some point
in the future, need to be able to fix this and not know how.

oh and just fyi, I've been deleting the build directory each time to
make sure I am not dealing with residual 'junk'. The .py file i'm
py2exe'ing really has almost nothing in it:

import pygame

pygame.init()

print "This is a very simple pygame sample for testing py2exe"


I wouldn't *think* that this would import Numeric or OpenGL or
anything fancy.  But then I am not an expert!

~Denise

On 9/18/05, Guillaume Proux <gproux@xxxxxxxxxxxxxx> wrote:
> Best is to first understand why those warning happen:
> 
> let's take an example: imagine you have the following code snippet deep
> inside one of the library you use for your game
> 
> if os.name == 'macosx':
>     import Foundation as mod
> else:
>     import defaultmod as mod
> 
> When analyzing the module for inclusion in the "library.zip", py2exe
> looks for all import statement in the files.
> 
> As it is in the case above, some import statement are meaningful only in
> the case of a certain operating system, but it will still be analyzed by
> py2exe as necessary. So in the end, the module that probably does not
> even exist on your OS cannot be found by py2exe and will be left out of
> the final executable.
> 
> You can have another case of problems that can happen with py2exe.
> 
> Some modules (such as the excellent cElementTree) are built entirely
> from a C library and directly call native Python APIs to import other
> modules. Such things, py2exe cannot detect them and the only way for
> py2exe to find then out and include them will be to import them manually
> in the main source file for example.
> 
> I don't fully explain why you get errors with pygame.movie etc. but you
> could try to import them directly like this if the need ever arise:
> 
> from pygame import movie
> from pygame import movieext
> from pygame import overlay
> 
> Regards,
> 
> Guillaume
>