views:

21

answers:

2

Found some info on porting packages from python 2 to 3 using distribute setuptools in below link.

http://packages.python.org/distribute/python3.html

I have a C api which could be build using python 2.x, but i need to build it in python 3.x. Can it be done using distribute.

Do anyone have idea on this?

+1  A: 

No, it cannot be done using Distribute. Distribute just calls the 2to3 script in the build phase, but 2to3 can convert only between Python 2.x source files and Python 3.x source files. For the C API, you have to do it the hard way by manually tweaking your code to compile with both Python APIs.

A very incomplete list of C API changes between Python 2.x and Python 3.x is to be found here. The same document also outlines the major differences between Python 2.x and 3.x on the Python source code level.

Tamás
+1  A: 

distriubte uses Python's 2to3 tool to automatically (try to) convert Python 2 code to Python 3 code. However, that only works for code written in Python. C code needs to be ported by hand.

The good news is that Python's C API has not changed much between Python 2.6 and 3.1. The main difference is that Python 3 now uses Unicode for all strings and has a separate bytes type for handling raw binary data.

Daniel Stutzbach