[vtk-developers] VTK_ENABLE_KITS and VTK_ENABLE_VTKPYTHON

Ben Boeckel ben.boeckel at kitware.com
Thu Jul 17 21:40:42 EDT 2014


On Fri, Jul 18, 2014 at 09:16:17 +1000, Andrew Maclean wrote:
> Let me know what I can do in the way of reconfiguring the python tests so
> that they run on both Python 3.x and Python 2.6+. I'm happy to spend time
> doing this.

A dashboard machine would be nice :) . Preferably continuous and/or
gerrit, but nightly would be a start.

> I think you are going to have to ultimately bump up the Python version
> especially if we want to support Python 3. Currently I think it is 2.5 so
> going to 2.6 would be Ok or even 2.7!!!

It is *possible* to support 2.4 through 3.3 with the same code, but
here's a (almost certainly incomplete) list of things which you have to
do in non-Pythonic ways:

  - Exception catching must be done as:

    catch MyException: # 'as' isn't allowed in 2.4; ',' isn't in 3.0
       exc = sys.exc_info()[1] # 0 is the type, 2 the backtrace

  - print can't be used if you use any keyword arguments or
    redirections:

    print('%d' % bar) # use parens and format strings
    ostr.write('%d\n' % bar) # use the write method for redirection
    sys.stdout.write('4') # write to stdout directly to not get a newline

  - Metaclasses can't be done (the only way in 2 and 3 is a syntax error
    in the other). Not used much (at all?) in VTK.

  - No 'with' statement (2.5 has it though).

> I remember trying to make Python code run on earlier versions by testing
> for the Python version, unfortunately the python interpreter seems to
> precompile all branches so this approach failed. I never found a solution.
> So this is another argument for bumping the version

Yep, a lot of issues arise from the fact that some changes are syntax
errors in the other version. PyPy has a plan to support Python2 and
Python3 running at the same time, but it might be a moot question by the
time that ever happens.

> It might be an idea to put it out to the community to see who is actually
> using Python 2.5 or earlier with VTK 6.0 and if so would they see any
> problems upgrading to Python 2.7.

RHEL5 ships with 2.4 and is probably still floating around in some
places. 2.6 is available, but not from Red Hat (it's in EPEL). Other
than that, 2.6 is probably a safe bet. 2.7 is becoming more common as
well.

> We really should be supporting Python 3.x because that is where all the
> Python development is going on now and I suspect that Numpy and SciPy will
> be focussing their efforts there too.

I've had performance issues in Python3 (as in significantly worse than
Python2) in other, non-VTK projects (mainly regex-related), but I don't
know how many of VTK's use cases are affected. It's something to keep an
eye out for though.

--Ben



More information about the vtk-developers mailing list