pyglet running on Python 3.x

693 views
Skip to first unread message

Andreas Schiefer

unread,
Aug 9, 2010, 2:15:13 PM8/9/10
to pyglet-users
Hi all,

I've just started an experimental conversion of pyglet-trunk to Python
3.x - mainly using the 2to3 script and some manual bug fixing
afterwards.

All the basic features like opening windows, handling input and
calling OpenGL functions are working just fine. Loading images works
through the platform specific codec - the codecs implemented in pure
python seem to have some problems. Also the whole pyglet.image module
needs some fixing, because it uses string regexes for the image data
that is now stored as bytes.

For testing purposes I've also converted simplui (http://
code.google.com/p/simplui/) to work with Python 3.x, which runs great
with the converted version of pyglet.

Currently, I've tested everything in Linux and Windows.

The source is available at http://code.google.com/r/andreasschiefer-pyglet-py3/
for everyone to try out.
(I can also provide the source of the ported simplui if anyone is
interested in it)

As there are probably still many bugs, patches are of course welcome!


Andy

Richard Jones

unread,
Aug 10, 2010, 8:31:54 PM8/10/10
to pyglet...@googlegroups.com
On Tue, Aug 10, 2010 at 4:15 AM, Andreas Schiefer
<andreas....@gmail.com> wrote:
> I've just started an experimental conversion of pyglet-trunk to Python
> 3.x - mainly using the 2to3 script and some manual bug fixing
> afterwards.

That's awesome. My personal pyglet wishlist has python 3 and 64-bit
support on it. Yay for python 3 support! :-)


> All the basic features like opening windows, handling input and
> calling OpenGL functions are working just fine. Loading images works
> through the platform specific codec - the codecs implemented in pure
> python seem to have some problems. Also the whole pyglet.image module
> needs some fixing, because it uses string regexes for the image data
> that is now stored as bytes.

What's the status of pyglet.text?


> The source is available at http://code.google.com/r/andreasschiefer-pyglet-py3/
> for everyone to try out.

I'd be perfectly happy for that to be contributed to the pyglet repository...


Richard

Andreas Schiefer

unread,
Aug 11, 2010, 5:29:25 AM8/11/10
to pyglet-users
On 11 Aug., 02:31, Richard Jones <r1chardj0...@gmail.com> wrote:
> What's the status of pyglet.text?

Well, the input_text.py example from the "examples" directory works
just fine, as does the ported simplui GUI toolkit (which also uses
pyglet.text for some of its widgets). The html_label.py example, on
the other side, does currently not work. So, it still needs some
fixing...


> I'd be perfectly happy for that to be contributed to the pyglet repository...

Ok, I'm just thinking of the best way to do it. Just committing the
changes as a separate py3-branch would require to port all future
changes to pyglet manually. The other possibility would be to backport
the necessary changes in a way compatible to Python 2.x, so that
creating a Python 3 version can simply be done by running the 2to3
script over the whole source. But I don't think all changes can be
backported that way (thinking of bytes vs. string).

Any opinions?


Andy

Andreas Schiefer

unread,
Aug 11, 2010, 7:31:01 AM8/11/10
to pyglet-users


On 11 Aug., 11:29, Andreas Schiefer <andreas.schie...@gmail.com>
wrote:
> On 11 Aug., 02:31, Richard Jones <r1chardj0...@gmail.com> wrote:

> > What's the status of pyglet.text?
>
> Well, the input_text.py example from the "examples" directory works
> just fine, as does the ported simplui GUI toolkit (which also uses
> pyglet.text for some of its widgets). The html_label.py example, on
> the other side, does currently not work. So, it still needs some
> fixing...

FYI: I've just committed another fix, now the html_label example also
works! (But there are probably still some bugs)

Gary Herron

unread,
Aug 11, 2010, 12:28:42 PM8/11/10
to pyglet...@googlegroups.com

This is how Numpy does it. They have a single code-base for both
Python2 and Python3, and run 3to2 during the installation process for
Python3. I don't know that this would work for Pyglet, but it's worth
investigating.

Also -- has anyone run the current pyglet through "python2.6 -3". I
just did, and it pointed out several things that probably ought to be
fixed in the current Pyglet before attempting to run 2to3.

Gary Herron


>
> Andy
>
>

Andreas Schiefer

unread,
Aug 11, 2010, 1:25:45 PM8/11/10
to pyglet-users
On 11 Aug., 18:28, Gary Herron <gher...@islandtraining.com> wrote:

> Also -- has anyone run the current pyglet through "python2.6 -3".    I
> just did, and it pointed out several things that probably ought to be
> fixed in the current Pyglet before attempting to run 2to3.

That are basically the things I've been fixing afterwards in my pyglet-
py3 repository for now. I agree that the warnings issued by the -3
switch are worth fixing in the current pyglet code base - that would
make converting with 2to3 much easier.
The bytes vs. string issue still remains though. I've looked at the
numpy sources, they have introduced some compatibility functions for
handling those types (http://svn.scipy.org/svn/numpy/trunk/numpy/
compat/py3k.py). Not sure how well that would fit into pyglet.


Andy

Andreas Schiefer

unread,
Aug 20, 2010, 2:31:07 PM8/20/10
to pyglet-users
On 11 Aug., 02:31, Richard Jones <r1chardj0...@gmail.com> wrote:
> I'd be perfectly happy for that to be contributed to the pyglet repository...

As of now, most changes from my repository have been backported to
pyglet-trunk, so that the pyglet source can be converted simply by
running

2to3 -w -n pyglet

from within the pyglet root directory (I haven't yet fixed examples,
tests, etc.)


For the bytes vs. string issue I've introduced the compat.py module
(inspired by that of numpy), which provides asstr() and asbytes()
functions to handle these types correctly with the different Python
versions.

What I've not tested at all is how well everything works on Mac OS, as
I've no access to a mac. Can someone with a mac try some example
programs with Python 3 and the converted pyglet? (Some example
programs like opengl.py, graphics.py, html_label.py, etc. work just
fine with Python 3 - even without converting)
It may also be helpful to just run some pyglet examples with
"python2.6 -3" to point out errors on the mac.


Andy
Reply all
Reply to author
Forward
0 new messages