So close on py2exe with PyOpenGL

I played with getting a py2exe executable created from PyOpenGL today, and it is very close to working.  The basics:

from distutils.core import setup
import py2exe
import glob, os
import OpenGL
data_files = [
    (
        os.path.join('OpenGL','DLLS'),
        glob.glob( os.path.join( os.path.dirname( OpenGL.__file__ ), 'DLLS', '*.*' ))
    ),
]

if __name__ == "__main__":
    setup(
        windows=['shader_test.py'],
        options={
            "py2exe": {
                "includes": [
                    "ctypes", "logging",
                    'OpenGL.platform.win32',
                ] + [
                    'OpenGL.arrays.%s'%x for x in [
                        'ctypesarrays','ctypesparameters','ctypespointers',
                        'lists','nones','numbers','numpymodule','strings','vbo'
                    ]
                ],
                'skip_archive': True,
            },
        },
        data_files = data_files,
    )

Which collects all of PyOpenGL's plugins that are applicable for use in Win32 (basically the platform plugin and all of the major array plugins) and suppresses packing the collected Python files into a zip-file (skip_archive) so that the PyOpenGL code that looks for precompiled GLUT and GLE in OpenGL/DLLS will work. Unfortunately, at least on my test VM the PyOpenGL b2 doesn't actually include the contents of the DLLS directory after installation :( . I corrected that manually for now, but will need to fix that properly at some point.

 Problem is, even with that, the resulting exe (which I'm testing with the PyOpenGL_demo GLUT shaders test) just silently exits on my XP virtual machine. No traceback. Nothing. Just exits. The built directory structure seems fine, and it properly limits the PyOpenGL code to those extensions you actually import, but there's no actual, you know, 3D graphics. It could be that my ancient VM just can't handle the truth, but for now I've run out of time to play with it. It would be nice if there were a way in py2exe to specify e.g. don't pack *this* module, something like "not egg safe" in setuptools, so that the rest of the app can be packed normally and just the one module would get unpacked into the filesystem.

Comments

  1. Alex Grönholm

    Alex Grönholm on 04/02/2014 4:04 p.m. #

    Have you tried this with cx_freeze? I personally prefer that one because py2exe was discontinued 6 years ago.

  2. Norman Denayer

    Norman Denayer on 04/02/2014 11:18 p.m. #

    I used py2exe for years but recently I had many issues to bundle the last wxPython release. Then I switched to PyInstaller... very impressive and works very well with third-party packages.

  3. Jason Marshall

    Jason Marshall on 04/03/2014 6:28 a.m. #

    I don't trust py2exe anymore even when it does work for me. Three years ago, I built a console application using py2exe and it ran fine on my computer but would not run on my coworker's almost identical computer.

  4. Mike Fletcher

    Mike Fletcher on 04/03/2014 9:12 a.m. #

    I haven't tried any other ones so far, as I've only been asked about py2exe (and seen Stack Overflow questions on it).

  5. Giovanni

    Giovanni on 04/07/2014 4:18 a.m. #

    That’s because PyInstaller works out of the box for PyOpenGL, this is why you don’t get asked :)

Comments are closed.

Pingbacks

Pingbacks are closed.