| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
""" |
|---|
| 8 |
MPI for Python |
|---|
| 9 |
============== |
|---|
| 10 |
|
|---|
| 11 |
This package provides MPI support for Python scripting in parallel |
|---|
| 12 |
environments. It is constructed on top of the MPI-1/MPI-2 |
|---|
| 13 |
specification, but provides an object oriented interface which closely |
|---|
| 14 |
follows the MPI-2 C++ bindings. |
|---|
| 15 |
|
|---|
| 16 |
This module supports point-to-point (send, receive) and collective |
|---|
| 17 |
(broadcast, scatter, gather, reduction) communications of any |
|---|
| 18 |
*picklable* Python object. |
|---|
| 19 |
|
|---|
| 20 |
For objects exporting single-segment buffer interface (strings, NumPy |
|---|
| 21 |
arrays, etc.), blocking/nonbloking/persistent point-to-point, |
|---|
| 22 |
collective and one-sided (put, get, accumulate) communications are |
|---|
| 23 |
fully supported, as well as parallel I/O (blocking and nonbloking, |
|---|
| 24 |
collective and noncollective read and write operations using explicit |
|---|
| 25 |
file offsets, individual file pointers and shared file |
|---|
| 26 |
pointers). |
|---|
| 27 |
|
|---|
| 28 |
There is also full support for group and communicator (inter, intra, |
|---|
| 29 |
Cartesian and graph topologies) creation and management, as well as |
|---|
| 30 |
creating user-defined datatypes. Additionally, there is almost |
|---|
| 31 |
complete support for dynamic process creation and management (spawn, |
|---|
| 32 |
name publishing). |
|---|
| 33 |
""" |
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
name = 'mpi4py' |
|---|
| 40 |
version = open('VERSION.txt').read().strip() |
|---|
| 41 |
descr = __doc__.split('\n')[1:-1]; del descr[1:3] |
|---|
| 42 |
devstat = ['Development Status :: 5 - Production/Stable'] |
|---|
| 43 |
download = 'http://pypi.python.org/packages/source/%s/%s/%s-%s.tar.gz' |
|---|
| 44 |
|
|---|
| 45 |
classifiers = """ |
|---|
| 46 |
License :: Public Domain |
|---|
| 47 |
Operating System :: POSIX |
|---|
| 48 |
Operating System :: Unix |
|---|
| 49 |
Operating System :: MacOS |
|---|
| 50 |
Operating System :: Microsoft :: Windows |
|---|
| 51 |
Intended Audience :: Developers |
|---|
| 52 |
Intended Audience :: Science/Research |
|---|
| 53 |
Programming Language :: C |
|---|
| 54 |
Programming Language :: Python |
|---|
| 55 |
Topic :: Scientific/Engineering |
|---|
| 56 |
Topic :: Software Development :: Libraries :: Python Modules |
|---|
| 57 |
""" |
|---|
| 58 |
|
|---|
| 59 |
keywords = """ |
|---|
| 60 |
scientific computing |
|---|
| 61 |
parallel computing |
|---|
| 62 |
message passing |
|---|
| 63 |
MPI |
|---|
| 64 |
""" |
|---|
| 65 |
|
|---|
| 66 |
platforms = """ |
|---|
| 67 |
Linux |
|---|
| 68 |
Unix |
|---|
| 69 |
Mac OS-X |
|---|
| 70 |
Windows |
|---|
| 71 |
""" |
|---|
| 72 |
|
|---|
| 73 |
metadata = { |
|---|
| 74 |
'name' : name, |
|---|
| 75 |
'version' : version, |
|---|
| 76 |
'description' : descr.pop(0), |
|---|
| 77 |
'long_description' : '\n'.join(descr), |
|---|
| 78 |
'url' : 'http://mpi4py.scipy.org/', |
|---|
| 79 |
'download_url' : download % (name[0], name, name, version), |
|---|
| 80 |
'classifiers' : [c for c in classifiers.split('\n') if c], |
|---|
| 81 |
'keywords' : [k for k in keywords.split('\n') if k], |
|---|
| 82 |
'platforms' : [p for p in platforms.split('\n') if p], |
|---|
| 83 |
'provides' : ['mpi4py', 'mpi4py.MPI', 'mpi4py.libmpi'], |
|---|
| 84 |
'requires' : ['pickle'], |
|---|
| 85 |
'license' : 'Public Domain', |
|---|
| 86 |
'author' : 'Lisandro Dalcin', |
|---|
| 87 |
'author_email' : 'dalcinl@gmail.com', |
|---|
| 88 |
'maintainer' : 'Lisandro Dalcin', |
|---|
| 89 |
'maintainer_email' : 'dalcinl@gmail.com', |
|---|
| 90 |
} |
|---|
| 91 |
metadata['classifiers'] += devstat |
|---|
| 92 |
|
|---|
| 93 |
del name, version, descr, devstat, download |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
def ext_modules(): |
|---|
| 100 |
import sys |
|---|
| 101 |
|
|---|
| 102 |
libmpi = dict(name='mpi4py.libmpi', |
|---|
| 103 |
sources=['src/ext/libmpi.c'], |
|---|
| 104 |
depends=['src/ext/libmpi.h']) |
|---|
| 105 |
|
|---|
| 106 |
mpi = dict(name='mpi4py._mpi', |
|---|
| 107 |
sources=['src/ext/mpi.c'], |
|---|
| 108 |
depends=['src/ext/libmpi.h', |
|---|
| 109 |
'src/ext/config.h', |
|---|
| 110 |
'src/ext/compat.h', |
|---|
| 111 |
'src/ext/macros.h', |
|---|
| 112 |
'src/ext/fastdefs.h',]) |
|---|
| 113 |
|
|---|
| 114 |
pickle = dict(name='mpi4py._pickle', |
|---|
| 115 |
sources=['src/ext/pickle.c']) |
|---|
| 116 |
|
|---|
| 117 |
marshal = dict(name='mpi4py._marshal', |
|---|
| 118 |
sources=['src/ext/marshal.c']) |
|---|
| 119 |
|
|---|
| 120 |
mpi_swig = dict(name='mpi4py._mpi_swig', |
|---|
| 121 |
sources=['src/ext/mpi_swig.c'], |
|---|
| 122 |
depends=['src/ext/libmpi.h']) |
|---|
| 123 |
|
|---|
| 124 |
allext = [libmpi, mpi, pickle, marshal, mpi_swig] |
|---|
| 125 |
|
|---|
| 126 |
if sys.version_info >= (3,0): del allext[-1] |
|---|
| 127 |
return allext |
|---|
| 128 |
|
|---|
| 129 |
def headers(): |
|---|
| 130 |
return ['src/ext/libmpi.h'] |
|---|
| 131 |
|
|---|
| 132 |
def executables(): |
|---|
| 133 |
import sys, os |
|---|
| 134 |
from distutils import sysconfig |
|---|
| 135 |
comp_args = [] |
|---|
| 136 |
libraries = [] |
|---|
| 137 |
library_dirs = [] |
|---|
| 138 |
link_args = [] |
|---|
| 139 |
if not sys.platform.startswith('win'): |
|---|
| 140 |
py_version = sysconfig.get_python_version() |
|---|
| 141 |
cfgDict = sysconfig.get_config_vars() |
|---|
| 142 |
if '-pthread' in cfgDict.get('CC', ''): |
|---|
| 143 |
comp_args.append('-pthread') |
|---|
| 144 |
libraries = ['python' + py_version] |
|---|
| 145 |
for var in ('LIBDIR', 'LIBPL'): |
|---|
| 146 |
library_dirs += cfgDict.get(var, '').split() |
|---|
| 147 |
for var in ('LIBS', 'MODLIBS', 'SYSLIBS', 'LDLAST',): |
|---|
| 148 |
link_args += cfgDict.get(var, '').split() |
|---|
| 149 |
pyexe = dict(name='mpi4py', |
|---|
| 150 |
sources=['src/exe/python.c'], |
|---|
| 151 |
libraries=libraries, |
|---|
| 152 |
library_dirs=library_dirs, |
|---|
| 153 |
extra_compile_args=comp_args, |
|---|
| 154 |
extra_link_args=link_args) |
|---|
| 155 |
return [pyexe] |
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
from distutils.core import setup |
|---|
| 163 |
from mpidistutils import Distribution, Extension, Executable |
|---|
| 164 |
from mpidistutils import config, build, build_ext |
|---|
| 165 |
from mpidistutils import build_exe, install_exe, clean_exe |
|---|
| 166 |
LibHeader = lambda header: str(header) |
|---|
| 167 |
ExtModule = lambda extension: Extension(**extension) |
|---|
| 168 |
ExeBinary = lambda executable: Executable(**executable) |
|---|
| 169 |
|
|---|
| 170 |
def main(): |
|---|
| 171 |
""" |
|---|
| 172 |
distutils.setup(*targs, **kwargs) |
|---|
| 173 |
""" |
|---|
| 174 |
setup(packages = ['mpi4py'], |
|---|
| 175 |
package_dir = {'mpi4py' : 'src'}, |
|---|
| 176 |
headers = [LibHeader(hdr) for hdr in headers()], |
|---|
| 177 |
ext_modules = [ExtModule(ext) for ext in ext_modules()], |
|---|
| 178 |
executables = [ExeBinary(exe) for exe in executables()], |
|---|
| 179 |
distclass = Distribution, |
|---|
| 180 |
cmdclass = {'config' : config, |
|---|
| 181 |
'build' : build, |
|---|
| 182 |
'build_ext' : build_ext, |
|---|
| 183 |
'build_exe' : build_exe, |
|---|
| 184 |
'clean_exe' : clean_exe, |
|---|
| 185 |
'install_exe' : install_exe, |
|---|
| 186 |
}, |
|---|
| 187 |
**metadata) |
|---|
| 188 |
|
|---|
| 189 |
if __name__ == '__main__': |
|---|
| 190 |
|
|---|
| 191 |
from distutils import sysconfig |
|---|
| 192 |
cvars = sysconfig.get_config_vars() |
|---|
| 193 |
cflags = cvars.get('OPT') |
|---|
| 194 |
if cflags: |
|---|
| 195 |
cflags = cflags.split() |
|---|
| 196 |
for flag in ('-g', '-g3'): |
|---|
| 197 |
if flag in cflags: |
|---|
| 198 |
cflags.remove(flag) |
|---|
| 199 |
cvars['OPT'] = str.join(' ', cflags) |
|---|
| 200 |
|
|---|
| 201 |
main() |
|---|
| 202 |
|
|---|
| 203 |
|
|---|