[Distutils] Re: executable?

Berthold Höllmann hoel@germanlloyd.org
Mon Jul 8 03:30:01 2002


Paul Dubois <dubois1@llnl.gov> writes:

> 	Has anyone used distutils to build an executable? I have it
building a
> C library and then I need to build an executable based on that library
> using the same macro and library definitions and one new .c file
> containing the main.

In the early days of distutils I wrote:

from distutils.core import setup
from distutils.ccompiler import new_compiler
from distutils.command.build import build

opt_src = ["qp/qpalloc.c", "qp/qpmatrx.c", "qp/qpproc.c", "qp/qpvect.c",
           "qp/qpchol.c",  "qp/qporder.c", "qp/qpshut.c",
"qp/qpxlist.c",
           "qp/qpdata.c",  "qp/qpprepr.c", "qp/qpsolv.c", "qp/qpmain.c",
           "qp/qpprint.c", "qp/qpsymbo.c"]



def build_opt(self):
    CC = new_compiler()
    if sys.platform != 'win32':
        CC.add_library('m')
    import os.path
    opt_obj = CC.compile(opt_src)
    CC.link_executable(opt_obj, os.path.join("build/lib/", sys.platform,
'opt'))

class my_build(build):
    def run(self):
        build_opt()
        build.run(self)

setup (cmdclass     = {'build': my_build},
       name         = "PyQP",
       version      = "0.0.0",
       description  = "qp access for Python",
       author       = 'Berthold H"ollmann',
       author_email = "hoel@germanlloyd.org",
       packages = [''],
       )

which might be a starting point for your own code

Greetings

Berthold
-- 
Dipl.-Ing. Berthold Höllmann   __   Address:
hoel@germanlloyd.org        G /  \ L Germanischer Lloyd
phone: +49-40-36149-7374    -+----+- Vorsetzen 32/35    P.O.Box 111606
fax  : +49-40-36149-7320      \__/   D-20459 Hamburg    D-20416 Hamburg



This email contains confidential information for the exclusive attention
of the intended addressee. Any access of third parties to this email is
unauthorized. Any use of this email by not intended recipients like
copying, distribution, disclosure etc. is prohibited and may be
unlawful. When addressed to our clients the content of this email is
subject to the General Terms and Conditions of GL's Group of Companies
applicable at the date of this email. 

GL's Group of Companies does not warrant and/or guarantee that this
message at the moment of receipt is authentic, correct and its
communication free of errors, interruption etc.