On Tue, 10 Nov 2009 08:40:31 +0100, Simon Edwards <[email protected]> wrote: > Hello Phil and Friends, > > I'm (finally) digging into figuring out what I need to do for PyKDE to > support Python 3. There doesn't seem to be much written on the subject, > but I get the impression still that it is dead simple. It is just a > matter of generating the C++ using SIP and compiling the result against > the Python 3 headers and linking against Python 3's library? And then > possibly adding some API annotations to PyKDE to support the newer way > of doing things?
All the things you need to do aren't v3 specific. If PyKDE is using the up to date handwritten code APIs and annotations for v2 then v3 support is free. The first thing you need to do is to support the dynamic switching of APIs. This means making sure your handwritten code supports the generated type structures introduced in SIP v4.8 (http://www.riverbankcomputing.com/static/Docs/sip4/c_api.html#generated-type-structures) and corresponding function calls rather than the old generated type objects. The difference is that handwritten code can no longer assume that a particular type (like QString) is implemented as a class or a mapped type. While you're at it you should also support the use of the new (in SIP v4.10) SIP_PROTECTED_IS_PUBLIC #define to allow PyKDE to be built as much smaller .so files. However, this is optional. The main thing you need to do with annotations is to look at how const char * is used. In Python v2 it doesn't usually matter - everything is a string. In Python v3 you may want some handled as bytes and some as Unicode. Look at the Encoding argument annotation. As of PyQt v4.7 (using SIP v4.10) docstrings will (by default) be generated for all classes, methods and functions. New annotations (DocType and DocValue) have been added to allow you to override what appears as the type or default value of an argument in a docstring and allows them to be specific to the version of Python. PyQt docstrings will accurately reflect the API that is available to the user of their particular build of PyQt. As ever use, PyQt as an example. Phil _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
