Differences between revisions 1 and 2
Revision 1 as of 2009-06-30 20:25:58
Size: 1623
Editor: BramGeron
Comment: Create.
Revision 2 as of 2009-07-01 17:39:33
Size: 1502
Editor: BramGeron
Comment: It works on a machine without PyOpenGL.
Deletions are marked like this. Additions are marked like this.
Line 27: Line 27:
Tested with Python 2.6, py2exe version 0.6.9 and PyOpenGL version 3.0.0. Only tested the executable on a machine that had PyOpenGL already on it, going to test on a machine without it tomorrow. Tested with Python 2.6, py2exe version 0.6.9 and PyOpenGL version 3.0.0.

PyOpenGL is a set of Python bindings for the OpenGL graphical rendering library. It has a page on how to compile with py2exe, but it is outdated. Here's how I made it work for me, although it is quite wasteful in space.

  • In your setup.py, exclude OpenGL although you have PyOpenGL installed. I needed to explicitly include ctypes and logging to make it work, but maybe that depends on what things you use. My setup.py:

    from distutils.core import setup
    import py2exe
    
    setup(windows=['opdracht.py'],
          options={
              "py2exe": {
                  "includes": ["ctypes", "logging"],
                  "excludes": ["OpenGL"],
                  }
              }
          )
  • At the top of your main Python file, add the current directory ('.') to your sys.path:

    import sys
    sys.path += ['.']
  • Run setup.py py2exe.

  • Copy the OpenGL folder from PYTHONDIR\Lib\site-packages to your new dist\ directory. I think it's in C:\Python26\Lib\site-packages by default. You can leave out any *.pyc and *.pyo files.

I think that's what did the trick for me, now . If you need funky stuff like TK, WGL, or OpenGLContext, maybe the original tutorial by PyOpenGL helps.

Tested with Python 2.6, py2exe version 0.6.9 and PyOpenGL version 3.0.0.

--- Bram Geron

PyOpenGL (last edited 2010-07-19 02:22:55 by MarkReed)