The problem with PyOpenGL with py2exe is that it looks for the Version file when it starts up. What I did was change one of the startup files that tries to load "version", and wrap it with a try:except: so that if it can't open the file it will just use a default version number.
The other issue that you can run into is that the PyOpenGL binary depends on numarray. I don't know that it works with numarray, I think it only works with Numeric (numpy). But you still must have it installed. And with py2exe, you must also include the numarray .pyd files. numarray dynamically loads the files, so py2exe is not able to tell statically which files it depends on.
Here is my workaround:
def numarray_imports():
"""Num array doesn't report it's dependencies properly because
it does dynamic importing using exec('import *') instead of static
importing. But that's okay, this works around that problem
"""
numarray_types = ('Bool', 'Complex32', 'Complex64', 'Float32', 'Float64'
, 'Int16', 'Int32', 'Int64', 'Int8', 'UInt16', 'UInt32', 'UInt8')
#These are the basic ones
numarray_includes = ['numarray', 'numarray.libnumarray', 'numarray._ufunc']
for t in numarray_types:
numarray_includes.append('numarray._ufunc' + t)
return numarray_includes
setup(
options = {
'py2exe': {
'compressed':1
, 'optimize':2
, 'includes':numarray_imports()
, 'dll_excludes':['OPENGL32.dll', 'DDRAW.dll', 'GLU32.dll']
, 'dist_dir':',dist'
}
, 'build': {
'build_base':',build'
}
}
, data_files = [('images', images), ('lib', msvc_dlls())]
, zipfile = 'lib/sharedlib'
, windows = [pulmon]
, cmdclass = {'py2exe':build_installer}
)
By the way, it would be nice if the PyOpenGL script didn't require the version file by default. The script at fault is OpenGL/__init__.py. These are the lines at fault:
filename = os.path.join(os.path.dirname(__file__), 'version')
__version__ = string.strip(open(filename).read())
__build__ = int(string.split(__version__, '.')[3])
And this is my workaround:
filename = os.path.join(os.path.dirname(__file__), 'version')
try:
__version__ = string.strip(open(filename).read())
except IOError:
__version__ = "2.0.1.07"
__build__ = int(string.split(__version__, '.')[3])
John
=:->
|