math/mpgen, symm/multigen: Fix the various build scripts for Python 3.
* Put parentheses around `print' arguments.
* Write `raise EXC(VALUE)' rather than `raise EXC, VALUE' to raise
exceptions.
* Cope with `xrange' being renamed to `range' in Python 3.
* Cope with `long' not being a type name in Python 3.
* Cope with `execfile' not being available in Python 3.
* Cope with function-object attribute names being renamed in Python 3.
* Cope with `StringIO' being in `io' rather than `cStringIO' in Python
3, and with `StringIO.reset' not being available any more.
* Cope with `itertools.izip' not being available in Python 3.
* Cope with `OBJ.next' not being available in Python 3.
* Use an unpleasant hack to inject metaclasses, because the official
syntax is so different between the two versions.