1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
# Compile the mpipython executable containing
# the Scientific.MPI extension module
# Normally nothing needs to be changed below
import distutils
import distutils.sysconfig
import os, sys
from Scientific import N
cfgDict = distutils.sysconfig.get_config_vars()
# Name of the MPI compilation script.
mpicompiler = 'mpicc'
mpiinclude = '/usr/include/lam'
executable = 'mpipython'
if os.environ.has_key('USE_LAM'):
mpicompiler = 'mpicc.lam'
mpiinclude = '/usr/include/lam'
executable = 'mpipython.lam'
if os.environ.has_key('USE_MPICH'):
mpicompiler = 'mpicc.mpich'
mpiinclude = '/usr/lib/mpich/include'
executable = 'mpipython.mpich'
sources='mpipython.c Scientific_mpi.c'
extra_compile_args = ""
if N.package == "NumPy":
arrayobject_h_include = os.path.join(sys.prefix,
"%s/numpy/core/include"
% distutils.sysconfig.get_python_lib())
extra_compile_args = "-DNUMPY=1 -I"+arrayobject_h_include
linkforshared = cfgDict['LINKFORSHARED']
if sys.platform == 'darwin':
# Fix LINKFORSHARED for framework builds under MacOS
items = linkforshared.split()
frameworkdir = (sys.prefix, '')
while frameworkdir[1] != 'Python.framework':
frameworkdir = os.path.split(frameworkdir[0])
for i in range(len(items)):
if 'Python.framework' in items[i] and not os.path.exists(items[i]):
items[i] = os.path.join(frameworkdir[0], items[i])
linkforshared = ' '.join(items)
cmd = '%s %s -o %s -I../../Include -I%s -I%s %s %s -L%s -lpython%s %s %s' % \
(mpicompiler,
linkforshared,
executable,
mpiinclude,
cfgDict['INCLUDEPY'],
extra_compile_args,
sources,
cfgDict['LIBPL'],
cfgDict['VERSION'],
cfgDict['LIBS'],
cfgDict['LIBM'])
print 'cmd = ', cmd
os.system(cmd)
|