[PyOpenGL-Users] PyOpenGL and OpenGLContext with py2exe, tentative recipes
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ro...> - 2002-07-10 20:45:50
|
Okay, here's the basic recipe I'm using for OpenGL scripts using GL, GLU, WGL and GLUT: Basic (ugly, but working) approach: Use --excludes=OpenGL flag to py2exe: setup_gldraw py2exe -k --excludes=OpenGL this prevents the OpenGL package, or any sub-module from being included. This avoids the conflicts with the various __init__.* files. import Tkinter directly in your script if you use OpenGL.Tk (many scripts don't explicitly import Tkinter, they just use the environment from OpenGL.Tk, which will be excluded by the step above, so Tkinter won't get packaged up. Alternately use an --includes=Tkinter flag for py2exe copy (a subset of) the OpenGL package into your distribution directory (see below)... OpenGL Package Subset: The subset can exclude the scripts, demo and doc directories. For considerable space savings if you're not using an extension, you can exclude that extension's directory from OpenGL/GL/ (about 8MB savings on disk for systems with inefficient support for small files and no used extensions). If you don't want TOGL support, you can exclude that too. If you don't want WGL support, you can exclude that too (same for GLU, GLUT, etceteras). If you really don't care about space, just include the whole OpenGL package. It would be nice if py2exe had a way to specify _how_ to deal with a particular included module/package, instead of just specifying "include or exclude", so that we could say "if OpenGL.GL is imported, include this directory in the final dist", but oh well. OpenGLContext: OpenGLContext is a much simpler recipe. Basically, you have to explicitly import/include the _concrete_ Context class you want to use (because testingcontext tries to load your "favourite" context using an __import__ statement). So, add: from OpenGLContext import wxtestingcontext or from OpenGLContext import gluttestingcontext or from OpenGLContext import pygametestingcontext to your script, depending on which context you want to use. (You could alternately use an --includes=OpenGLContext.wxtestingcontext for the py2exe command if you prefer). You can import/include all of them if you want to include all of them (and all of the underlying libraries) for your app for some reason (such as a command-line switch that lets someone choose among them. I'd be happy if anyone had a better recipe for the PyOpenGL package, but the one above should work for now (though, of course, it doesn't help at all with getting OpenGL itself installed on older machines, that's an installer issue). Enjoy yourselves, Mike |