Re: [PyOpenGL-Devel] pyopengl and pypy
Brought to you by:
mcfletch
|
From: Mike C. F. <mcf...@vr...> - 2010-11-29 19:00:21
|
On 10-11-26 07:54 PM, rndblnch wrote: > hello, > > i'm trying to make my pyopengl(3.0.1)-based code run with pypy (1.4). > i ran into some issues: > 1) the use of ctypes.pythonapi (for PyString_AsString in arrays/strings.py and > PyBuffer_FromMemory in arrays/vbo.py) > 2) an "AttributeError: type object 'ArrayDatatype' has no attribute > '_CData_input'", trackback: > ... > File "/Users/Shared/src/pypy-1.4-osx/site-packages/OpenGL/latebind.py", line > 45, in __call__ > return self._finalCall( *args, **named ) > File "/Users/Shared/src/pypy-1.4-osx/site-packages/OpenGL/wrapper.py", line > 784, in wrapperCall > result = self.wrappedOperation( *cArguments ) > File > "/Users/Shared/src/pypy-1.4-osx/site-packages/OpenGL/platform/baseplatform.py", > line 335, in __call__ > return self( *args, **named ) > File "/Users/Shared/src/pypy-1.4-osx/lib_pypy/_ctypes/function.py", line 166, > in __call__ > argtypes, argsandobjs = self._wrap_args(argtypes, args) > File "/Users/Shared/src/pypy-1.4-osx/lib_pypy/_ctypes/function.py", line 281, > in _wrap_args > wrapped = argtype._CData_input(arg) > AttributeError: type object 'ArrayDatatype' has no attribute '_CData_input' > > i guess that for 1) it should be possible to write pure ctypes/python > replacements for the needed functions (any hints welcome :) > for 2) i didn't manage to understand enough the relationship between pyopengl > and ctypes to get any clue about what's going on. > > anybody with some experience with/interested by such issues? > I'm definitely interested, but have very little time these days to play with PyOpenGL. There's a lot of machinery in PyOpenGL that produces the ctypes array-wrapper functionality (in the OpenGL/arrays package for the most part), but in the end, it's just doing standard ctypes calls about 95% of the time. Every once in a rare while I had to use an undocumented implementation feature of ctypes, but I don't think that's the problem here. _CData_input looks to be something pypy-specific which would be the equivalent of the from_param method on CPython ctypes? I'm guessing the pypy implementation assumes an inheritance relationship among all data-types and that _CData_input is a method on their _CData class. For whatever reason, the subclasses of ctypes.POINTER( <constant-type> ) are not picking up that method. For the first issue, those are going to require some reworking, in essence those are "C" implemented code that happens to use Python/ctypes as the implementation language and makes assumptions about the data-storage for the objects (e.g. that a string is internally a contiguous series of bytes, which is *not necessarily* true in PyPy). We'd need to find a mechanism in PyPy that would give us that direct memory-pointer access to be able to use it. Note: a compacting garbage collector (or anything else that can move memory locations) will cause problems there, so we may need to find a way to signal PyPy not to move a given object, and to use contiguous data-arrays for their storage. HTH, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |