2015년 2월 20일 금요일

Latest pyglet 1.2 update breaks Brainworkshop - WORKAROUND

I upgraded Archlinux package python2-pyglet to version 1.2.0 from 1.1.4-2 on Feb. 19th:

[archjun@lenovoS310 log]$ tail pacman.log -n 30 |grep pyglet
[2015-02-19 19:10] [ALPM] upgraded python2-pyglet (1.1.4-2 -> 1.2.0-1)

Brainworkshop 4.8.4 gives the following error:

Traceback (most recent call last):
  File "/usr/share/brainworkshop/brainworkshop.pyw", line 4586, in
    updateLabel = UpdateLabel()
  File "/usr/share/brainworkshop/brainworkshop.pyw", line 2523, in __init__Postscript 2015-10-11
    anchor_x='center', anchor_y='center', batch=batch)
TypeError: __init__() got an unexpected keyword argument 'halign'

Looking at the the dunder function __init__() at around line 2523 reveals the following:


According to the pyglet.text.Label online documentation the halign keyword exists and is defined as follows:
Horizontal alignment of text on a line, only applies if a width is supplied. One of "left""center" or "right".
Perhaps the documentation only applies to versions < pyglet 1.2, because simply deleting the reference to halign in the code snippet above allows Brainworkshop to load without any errors.

Postscript 2015-12-20

This problem will occur if you have a recent version (> 1.2.0) of python2 pyglet installed on your system which will take precedence over the version of pyglet that is bundled in the Brainworkshop zip archive downloaded from Sourceforge. When using the pyglet files bundled in the BW zip, the program will run with halign = 'middle', halign = 'center' or even when halign is removed entirely.

I don't think it's a good idea to bundle pyglet with the Brainworkshop source, however. Better to tell users that pyglet is a dependency of BW and have them install it themselves; of course by bundling pyglet with the source, the developer can pin BW to a specific version of pyglet to avoid breakage in BW due to changes upstream. But this is a stopgap measure.