porting modules to Python 3.0
"Martin v. Löwis"
martin at v.loewis.de
Wed Dec 3 07:21:17 CET 2008
> Is there something like that already in place? What are the
> recommendations for library
> authors willing to support both Python 2.X and 3.X in parallel?
My recommendation is to use 3.0's build_py_2to3 implementation of
the build_py command. See Demo/distutils/test2to3.
You will have a single lib.py, written in 2.x. When you install
in 3.0, lib2to3 will convert it to 3.x in the build area, and
then install the 3.0 version.
That, of course, requires you to adjust lib.py in such a way that
2to3 will successfully and completely convert it. In my experience
(with porting Django) and Mark Hammond's experience (with porting
PythonWin), this should be always possible. You look at what 2to3
does, find out what additional modifications need to be done, and
apply them to the input of 2to3 so that
a) 2to3 leaves these changes in place
b) they either have no effect or still work correctly when run
More information about the Python-list