Python3 / PyPy compatibility

Bug #966796 reported by rockachu2
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
PyGL3Display
Confirmed
Medium
David Griffin

Bug Description

>>> from opengl.GL import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named opengl.GL
>>> from OpenGL.GL import *
>>>

Most of the examples/maybe some core code runs and asks for a module of OpenGL.GL. Unfortunately, it appears python 3.2 does not create a module for a directory, so this results in an error, whereas importing the whole directory doesn't result in an error.

For ease-of-use, you could place a module called 'gl' and in it:
from OpenGL.GL import *

and thus just import gl in the situations you need opengl, but that seems a rather inefficient way to do it, although I can't come up with a better solution.

Revision history for this message
David Griffin (habilain) wrote :

I'm not able to reproduce this error. I ran the 2to3 tool over PyOpenGL and...

habilain@HABTOP:~/Downloads/temp/PyOpenGL-3.0.2a5$ python3
Python 3.2.2 (default, Sep 5 2011, 21:17:14)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import OpenGL
>>> import OpenGL.GL
>>> from OpenGL.GL import *

Which would indicate that all is well. I also did a quick search over my files and "opengl.GL" never occurs, and incidentally also stops the programs running on Python 2.

Now, I've no idea on actual Python 3 compatibility of PyGL3Display. I tried to compile pygame for Python 3 and, well, it won't work. Not sure what's causing that.

However, I've got to point out: Python 3 compatibility is not a priority. The goal of PyGL3Display is high performance, and, as such the main priority has to be removing the dependency on PyGame entirely so that it can run on top of PyPy - which is (presently) a Python 2 implementation.

David Griffin (habilain)
Changed in pygl3display:
status: New → Incomplete
importance: Undecided → Low
Revision history for this message
David Griffin (habilain) wrote :

An update on the Python3 situation now that there is a GLUT backend which eliminates my problems with Pygame: PyOpenGL does not appear to run correctly on Python3 (due to str/bytes distinction causing some problems).

Now, because PyOpenGL is *also* incompatible with PyPy, it looks likely that I'll be attempting to write my own GL wrapper at some point, at which point I'll try to make it work with Python3 as well. Until then, only Python 2.x can be supported.

summary: - python 3 importerror
+ Python3 / PyPy compatibility
Changed in pygl3display:
status: Incomplete → Confirmed
importance: Low → Medium
assignee: nobody → David Griffin (habilain)
Revision history for this message
David Griffin (habilain) wrote :

As this has come up a few times, I've changed branding so that it clearly states not compatible with Python 3

Revision history for this message
David Griffin (habilain) wrote :

Update on status: PyGL3Display will switch to using CFFI (https://bitbucket.org/cffi/cffi) and calling the OpenGL libraries without a cTypes intermediary. CFFI at present only targets cPython 2.x, but intends to support both PyPy and Python3, thus making it a good fit.

Other alternatives have been looked at, including the just released Pyglet 1.2 alpha. Whilst this supports Python3, it does not work under PyPy, making it a poor fit. It appears that in general, whilst cTypes does work for trivial applications under PyPy, there are instances where legitimate (albeit somewhat poorly defined) code that is valid for cPython-ctypes does not work under PyPy-ctypes.

Revision history for this message
David Griffin (habilain) wrote :

Update on status: The CFFI binding for PyGL3Display has been completed. Pypy compatibility will come soon; Python3 a little after that. Before this can happen I need to implement a better way of getting GL contexts etc, especially as Pypy cannot support the current preferred context of Pygame.

Revision history for this message
David Griffin (habilain) wrote :

Update on status: In trunk, the CFFI binding is more or less complete, but presently is only enabled under Linux. It also comes with most of a binding onto GLFW, which means that it is now possible to run some programs under PyPy. Unfortunately, the GLFW binding does not yet support getting input, due to some problems with C defines that CFFI cannot parse. Python3 support has not been tested yet, but theoretically should not take too long.

Revision history for this message
David Griffin (habilain) wrote :

Update on status: With the release of CFFI 0.6 and PyPy 2.0 Beta 2, PyGL3Display, using the GLFW backend, works nicely on PyPy (under Linux). Non-Linux and Python3 support is being worked on.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.