Can Distribute setuptool be used to convert Python 2 packages to Python 3? [duplicate]
Possible Duplicate:
Can distribute setuptools be used to port packages implemented in python 2 to 3
Also, does the tool make it easy?
The only thing that Distribute does is that it calls the 2to3
script (supplied with Python 3) that converts a Python 2.x source code to Python 3 using some automatic transformations. Basically, you write your code using Python 2.x and let Distribute convert it to Python 3 when your package is installed on Python 3.
There are several things that Distribute won't do for you, though:
It won't check whether the conversion succeeded or not. You should have a fairly exhaustive set of unit tests to ensure that the behaviour of the converted package is correct as not all the transformations can be done automatically by
2to3
, and some other transformations it will do might not make sense. Read this case study for more information about porting a real Python package to Python 3 and in particular this section about things not handled by2to3
.It won't convert modules written using the C API of Python (see this question), you will have to convert these yourself.
精彩评论