distutils and libraries

Nick Gnedin ngnedin at gmail.com
Tue Apr 23 10:29:59 EDT 2013


Folks,

I would like to install a Python module from a complete library. So, my 
question: if I already have a fully build Python module libMyModule.so, 
is there a way to use setup.py to just install it, skipping the build step?

Here are details if needed:

My build process consists of 2 steps - first, I build a static library 
libtemp.a (using CMake) that depends on 3rd party software. From that 
library I build a python module by compiling the file my_py.cpp that 
contains PyInit_MyModule function etc for proper module initialization.

I can build that module in two ways: by using CMake or distutils. CMake 
builds the module properly, finding all dependencies, and when I install 
it manually, everything works just fine - but then the problem is that 
it has to be installed manually. With distutils, when I use

module1 = Extension('ifrit',
                     libraries = ['temp'],
                     library_dirs = ['.'],
                     sources = ['my_py.cpp'])

the module is build and installed, but when I import it, it does not 
find the 3rd party libraries and complain about undefined symbols.

Adding all 3rd party library paths to setup.py is not an option - those 
can be installed by a user anywhere. So, ideally, I would like to do 
something like that

module1 = Extension('ifrit',
                     libraries = ['MyModule'],
                     sources = [])

where libMyModule.so is a complete Python module build by CMake, but 
that does not work because setup.py still tries to build the module from 
an already existing complete module, and just creates an empty library.

So, my question again: if I already have a fully build Python module 
libMyModule.so, is there a way to use setup.py to just install it, 
skipping the build step?

Many thanks for any help,

Nick Gnedin







More information about the Python-list mailing list