Creating python c module independent of python version?
In Tcl, there is a concept of stubs, where you can have a C extension that works with any compatible version of Tcl. Is there a comparable concept for Python?
I'd like to distribute a binary module that would run on Ubuntu 8.04 (python 2.5), Ubuntu 10.04 (python 2.6), and Centos 5 (python 2.4). I'd like to only have to distribute a 32 bit and a 64 bit version for Linux that would be compatibl开发者_如何学运维e with all 3. I'd redistribute libstdc++ and compile for glib 2.7 which is forward compatible with glib 2.11.
If you distribute your module as source, it can be compiled as necessary.
This problem occurs a lot with Windows, for which modules are normally distributed as binaries. PEP 384 proposes a solution (a limited interface which is guaranteed to exist for all Python 3 versions) and is implemented in Python 3.2. Until then, you're stuck.
精彩评论