[vtkusers] VTK Python3 support

Arnd Baecker arnd.baecker at web.de
Tue Mar 10 03:45:42 EDT 2015


As a follow-up concerning the conversion of the .py files:
I have run the current 6.2 release through pylint
with --py3k option.

Excluding everything from the ThirdParty directory
(which for example contains Twisted 14.0.0 which
is not yet ported to Python 3)
this is only approx 780 python files.

One gets a total of 3130 violations spread over 745 files.

Out of these there are:
- 2325 violations W1618
   (missing `from __future__ import absolute_import`)
   Adding this line actually might not be necessary, it just indicates
   that this behaviour is the default on python 3.
- 552 violations E1601
   print statement.
   This can be easily solved using
    from __future__ import print_function
   and converting all print-statements to  print(...)
- 53 violations  E1604
   syntax change in raise

So this leaves some further 200 violations spread over 72 files.
These have to be looked at individually.
Several warn about the change in division
(which can be solved using ``from __future__ import division``
and using // instead of the current usage of /.

Overall that part seems doable with reasonable effort
(But maybe I am seeing things too optimistic
or I am overlooking something ...).
In the end this would mean that all examples and tests
could (in principle) be run both on python 2 and python 3
without any further code changes.
Moreover, ThirdParty already contains SixPython
which could be used if there are changes like range vs. xrange etc.

Are there automatic tests runs
a) for the python code?
b) to determine code-coverage for VTK
    (including the python side)?
This would help to prevent any regression
during the above steps.

Concerning the first two points of David:
> 1) VTK wrapping still uses old-style classes.  I've been meaning to fix this.
> 2) Basic compile issues and cross-compatibility for py3 and py2 -
>    we received a patch that fixes some of these issues.
I have no clue how much work this is...

Best, Arnd


More information about the vtkusers mailing list