Using a static library in a C extension for Python

Chris Angelico rosuav at gmail.com
Wed Jan 22 21:33:16 EST 2014


On Thu, Jan 23, 2014 at 10:00 AM, Christian Gollwitzer <auriocus at gmx.de> wrote:
> There might be another issue with the license of the library. Cairo is both
> LGPL and MPL. For LGPL, only dynamic linking is without doubt, for MPL it
> seems to be accepted to link statically. It all depends on whether you plan
> to pass on the binary to another person.
> To circumvent this problem, it might be feasable to just install libcairo
> along with you extension.
>
> Then, the exact same version of python must be used on both computers. Since
> the extension loading mechanism completely relies on the OS dynamic linker,
> it is not possible to load an extension into a different version of python
> than it was built for.

If you can tie in with your OS's package manager, that would solve all
of these problems. You get the OS-supplied Pythom and the OS-supplied
libcairo; grabbing libcairo-dev (or, on my Debian system,
libcairo2-dev to go with libcairo2) gets you what you need to build
your extension; you then might even package your extension the same
way, and then simply declare dependencies. Can save a HUGE amount of
trouble.

ChrisA



More information about the Python-list mailing list