[Distutils] Question about libraries

Thomas Heller thomas.heller@ion-tof.com
Tue Jun 11 12:00:08 2002


> I want to use distutils to build an ordinary C library for subsequent
> use in other parts of my build. I have a setup file that contains this
> call to setup:
> 
> setup (name = "libcmds",
>        ...
>        libraries = [
>                       ('cdms',
>                           {'sources': sourcelist,
>                            'macros': macros,
>                            'include_dirs': include_dirs,
>                            'library_dirs': library_dirs,
>                           }
>                       ),
>                   ]
>  This works and I can build the library libcdms.a, but it is put in
> build/temp.linux-i686-2.2, hardly the kind of place I want to refer to
> in other parts of my build. Is there a way to install it somewhere? Or
> get back the name of the library file so that I can move it myself?

It seems the directory is available as the 'build_clib' attribute of
the 'build_clib' command. You can retrieve it, for example, in your own
build_ext command (or maybe better in your install_lib command):

from distutils.command import install_lib

class my_install_lib(install_lib.install_lib):
    def run(self):
        install_lib.install_lib.run(self)
        build_lib = self.get_finalized_command("build_clib")

        # now install the clib somewhere else

and later:

setup(...,
      cmdclass = {'install_lib': my_install_lib},
      ...)

Does this help?

Thomas