Python distutil: build libraries before modules

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bo Peng

    #1

    Python distutil: build libraries before modules

    Dear list,

    My python modules depend on a few boost libraries. For convenience, I
    include the source code of these libraries with my distribution and
    treat them as standard source files. This results in huge cc.exe command
    lines and I get an error saying
    error: command 'cc' failed: Invalid argument
    under win32/mingw. (I am not quite sure this is the reason though.)

    How can I let setup.py build these boost libraries separately so that I
    can link them to my modules? This will also save some link time because
    all my python modules link to the same boost libraries.

    Many thanks in advance.
    Bo
  • Bo Peng

    #2
    Re: Python distutil: build libraries before modules

    Bo Peng wrote:
    [color=blue]
    > How can I let setup.py build these boost libraries separately so that I
    > can link them to my modules? This will also save some link time because
    > all my python modules link to the same boost libraries.[/color]

    Although this is nowhere documented, I find that I can use

    from distutils.ccomp iler import *

    def buildStaticLibr ary(sourceFiles , libName, libDir):
    '''Build libraries to be linked to simuPOP modules'''
    # get a c compiler
    comp = new_compiler()
    objFiles = comp.compile(so urceFiles)
    comp.create_sta tic_lib(objFile s, libName, libDir)

    to build the libraries

    Cheers,
    Bo

    Comment

    Working...