How to distribute C/C++ python extension module on Linux?

David Cournapeau cournape at gmail.com
Fri Dec 5 03:36:45 EST 2008


On Fri, Dec 5, 2008 at 5:09 PM, Allen <Allen.Chenal at gmail.com> wrote:
> I have build an extension module PyRPC.so (why not be libPyRPC.so?).
> The PyRPC.so uses API in libRPCPacker.so.
> How to distribute the PyRPC.so?

The simple answer is you can't. Depending on the distribution, the
python interpreter is built differently in an ABI-incompatible way. As
on other platforms, the binary also depends on the python version.

The only real solution is to package it using the native package
manager of the distributions you are interested in supporting (rpm,
deb, etc...); you still have to build the package for all different
combinations, though. Something like the opensuse build service can
help in those situations.

> I just put PyRPC.so and libRPCPacker.so in the same folder.
> And under this folder, run python.
> It tells PyRPC module cannot find a method in libRPCPacker.so.

We need more informations on how you built the extension, and about
the exact error message. Note also that on Linux, by default,
libraries are not looked in the current directory, so it is likely
that PyRPC.so does not look in the libRPCPaker.so in your current
directory, but from another path (you can check how the loader
resolves libraries paths with the command ldd).

David



More information about the Python-list mailing list