On Tue, Jan 8, 2013 at 12:18 PM, Christoph Gohlke <
cjgo...@gmail.com> wrote:
>
>
> What is the purpose of shipping python-mpi.exe with mpi4py
> <
http://code.google.com/p/mpi4py/source/browse/setup.py#418>?
>
python-mpi.exe is shipped for old MPI implementations that do require
at MPI_Init() the command line arguments passed to main(). In this
case, it is impossible to use the stock python.exe executable.
However, I do not know any MPI implementation for Windows that has
this issue. Other use case would be to generate a Python binary that
statically links the MPI libraries.
> Users are not required to use python-mpi.exe. It is a shortcut/workaround
> for the reported problem, where OpenMPI is not present or set up correctly.
> Users are free to set OPENMPI_HOME and PATH environment variables to any
> compatible OpenMPI installation.
>
Oh! I see...
> I am considering adding the following code to mpi4py/__init__.py so my
> binaries work with the standard python.exe out of the box.
>
> ```
> def _init_openmpi():
> """Pre-load libmpi.dll and register OpenMPI distribution."""
> import os
> import ctypes
> if
os.name != 'nt' or 'OPENMPI_HOME' in os.environ:
> return
> try:
> openmpi_home = os.path.abspath(os.path.dirname(__file__))
> openmpi_bin = os.path.join(openmpi_home, 'bin')
> ctypes.cdll.LoadLibrary(os.path.join(openmpi_bin, 'libmpi.dll'))
> os.environ['OPENMPI_HOME'] = openmpi_home
> os.environ['PATH'] = ';'.join((openmpi_bin, os.environ['PATH']))
> except Exception:
> pass
>
> _init_openmpi()
> ```
If that hackery makes your binaries work out of the box with the stock
python.exe, then go ahead and ship the modified mpi4py/__init__.py
with your binaries. But... Do you really need to preload libmpi.dll ?
I have little knol about dynamic loading on Windows, but AFAIK, the
preloading is useless... the PATH fixing is what really makes it
working.
BTW, will you also ship "mpiexec.exe" in the mpi4py/bin directory?