[Distutils] executable?

Konrad Hinsen hinsen@cnrs-orleans.fr
Sat Jul 6 04:09:28 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.

I have a script that builds a new Python executable (with additional
builtin modules) and which gets all system information from distutils,
but it then makes explicit system calls to run the compilation. I
couldn't find any helper functions for this within distutils.

Here is the script:

---------------------------------------------------------------------------
# Compile the mpipython executable containing
# the Scientific.MPI extension module

# Normally nothing needs to be changed below
import distutils
import distutils.sysconfig
import os  

cfgDict = distutils.sysconfig.get_config_vars()

# Name of the MPI compilation script.
mpicompiler = 'mpicc'
sources='mpipython.c Scientific_mpi.c'


cmd = '%s %s -o mpipython -I%s %s -L%s -lpython%s %s %s' % \
    (mpicompiler, 
    cfgDict['LINKFORSHARED'],
    cfgDict['INCLUDEPY'],
    sources,
    cfgDict['LIBPL'],
    cfgDict['VERSION'], 
    cfgDict['LIBS'], 
    cfgDict['LIBM'])

print 'cmd = ', cmd 
os.system(cmd)
---------------------------------------------------------------------------

Konrad.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen@cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------