py2exe Script (copy to gamelib folder)

class MediaCollector(build_exe):
    def copy_extensions(self, extensions):
#        super(MediaCollector, self)
        build_exe.copy_extensions(self, extensions)

        # Create the media subdir where the
        # Python files are collected.
        media = os.path.join('..', 'data')
        full = os.path.join(self.collect_dir, media)
        if not os.path.exists(full):
            self.mkpath(full)

        # Copy the media files to the collection dir.
        # Also add the copied file to the list of compiled
        # files so it will be included in zipfile.
        for f in glob.glob(os.path.join('..','data/*')):
            name = os.path.basename(f)
            self.copy_file(f, os.path.join(full, name))
            self.compiled_files.append(os.path.join(media, name))


py2exe_options = {
            'cmdclass': {'py2exe': MediaCollector}
            #'bundle_files':1
                # [...] Other py2exe options here.
                }
setup(windows= ['run_game.py'], **py2exe_options

(log in to comment)

Comments

http://pastebin.com/d23d3cb1f
will last there for a day.. pick it up while you can.. :)
Works great, except it doesn't seem to work for pyopengl :(

Traceback (most recent call last):
  File "run_game.pyw", line 4, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "main.pyc", line 2, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "pyggel\__init__.pyc", line 7, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "pyggel\include.pyc", line 12, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "OpenGL\GL\__init__.pyc", line 2, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "OpenGL\raw\GL\__init__.pyc", line 6, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "OpenGL\raw\GL\constants.pyc", line 7, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "OpenGL\platform\__init__.pyc", line 36, in <module>
  File "OpenGL\platform\__init__.pyc", line 27, in _load
  File "OpenGL\plugins.pyc", line 14, in load
  File "OpenGL\plugins.pyc", line 28, in importByName
ImportError: No module named win32

Arg - anyone managed to bundle pyopengl 3.0.x yet?
dude.. you can totally fix this..
python setup.py py2exe --excludes=pyopengl

and copy the whole pyopengl module from site-packages to dist folder
ok, let me try that
Hmm, tried that, same error.
Apparently I need to find win32.dll - course I can't do that for some reason :S
Managed to get everything included, so now it segfaults...
At least it's progress... eh?

Will try again tomorrow :S
Check the segfault is not because of using pygame.font.Font(None, <size>).

to fix that segfault, replace all calls to pygame.font.Font(None...
with pygame.font.Font("path/to/filenamehere.ttf"...
and include your ttf in with your distribution.
 
My money is on that.
OH?
Thank you for the info - will try again later sometime :)

Unfortunately too late to upload an exe, but as long as everyone reads ReadME's (which they won't :( ) it should be easy enough to run...