Blob Blame History Raw
%if 0%{?fedora} > 12 || 0%{?rhel} > 6
%global with_python3 1
%endif

%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}

### TESTSUITE ###
# The testsuite currently fails only on the buildsystem, but works localy.
# So to easy enable/disable the testsuite, I introduce the following
#   variables:
#
# * MPD:       if '1' enable mpich2, which requires mpd to start
# * OPENMPI:   if '1' enable openmpi
%global MPD 0
%global OPENMPI 0

Name:           mpi4py
Version:        1.2
Release:        7%{?dist}
Summary:        Python bindings of the Message Passing Interface (MPI)

Group:          Development/Languages
License:        BSD
URL:            http://mpi4py.scipy.org
Source0:        http://mpi4py.googlecode.com/files/mpi4py-%{version}.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires:  python-devel
%if 0%{?with_python3}
BuildRequires:  python3-devel
%endif
Requires:       %{name}-common = %{version}-%{release}

# for the testsuite: 'pwgen' is needed to create a random password
BuildRequires:  pwgen



%description
This package is constructed on top of the MPI-1/MPI-2 specification and
provides an object oriented interface which closely follows MPI-2 C++
bindings. It supports point-to-point (sends, receives) and collective
(broadcasts, scatters, gathers) communications of any picklable Python
object as well as optimized communications of Python object exposing the
single-segment buffer interface (NumPy arrays, builtin bytes/string/array
objects).

%package docs
Summary:        Documentation for %{name}
Group:          Documentation
BuildArch:      noarch
Requires:       %{name} = %{version}-%{release}
%description docs
This package contains the documentation  and examples for %{name}.

%if 0%{?with_python3}
%package -n python3-mpi4py
Requires:       %{name}-common = %{version}-%{release}
Summary:        Python bindings of the Message Passing Interface (MPI)
Group:          Development/Languages
%description -n python3-mpi4py
This package is constructed on top of the MPI-1/MPI-2 specification and
provides an object oriented interface which closely follows MPI-2 C++
bindings. It supports point-to-point (sends, receives) and collective
(broadcasts, scatters, gathers) communications of any picklable Python
object as well as optimized communications of Python object exposing the
single-segment buffer interface (NumPy arrays, builtin bytes/string/array
objects).

%package -n python3-mpi4py-openmpi
BuildRequires:  openmpi-devel
Requires:       openmpi
Requires:       %{name}-common = %{version}-%{release}
Summary:        Python bindings of MPI, Open MPI version
Provides:       python3-mpi4py-runtime = %{version}-%{release}
%description -n python3-mpi4py-openmpi
This package is constructed on top of the MPI-1/MPI-2 specification and
provides an object oriented interface which closely follows MPI-2 C++
bindings. It supports point-to-point (sends, receives) and collective
(broadcasts, scatters, gathers) communications of any picklable Python
object as well as optimized communications of Python object exposing the
single-segment buffer interface (NumPy arrays, builtin bytes/string/array
objects).

This package contains %{name} compiled against Open MPI.


%package -n python3-mpi4py-mpich2
BuildRequires:  mpich2-devel
Requires:       mpich2
Requires:       %{name}-common = %{version}-%{release}
Summary:        Python bindings of MPI, MPICH2 version
Provides:       python3-mpi4py-runtime = %{version}-%{release}
%description -n python3-mpi4py-mpich2
This package is constructed on top of the MPI-1/MPI-2 specification and
provides an object oriented interface which closely follows MPI-2 C++
bindings. It supports point-to-point (sends, receives) and collective
(broadcasts, scatters, gathers) communications of any picklable Python
object as well as optimized communications of Python object exposing the
single-segment buffer interface (NumPy arrays, builtin bytes/string/array
objects).

This package contains %{name} compiled against MPICH2.
%endif # with_python3

%package common
Summary:        Common files for mpi4py packages
Group:          Documentation
BuildArch:      noarch
Requires:       %{name}-common = %{version}-%{release}
%description common
This package contains the license file shard between the subpackages of %{name}.

%package openmpi
BuildRequires:  openmpi-devel
Requires:       openmpi
Requires:       %{name}-common = %{version}-%{release}
Summary:        Python bindings of MPI, Open MPI version
Provides:       mpi4py-runtime = %{version}-%{release}
%description openmpi
This package is constructed on top of the MPI-1/MPI-2 specification and
provides an object oriented interface which closely follows MPI-2 C++
bindings. It supports point-to-point (sends, receives) and collective
(broadcasts, scatters, gathers) communications of any picklable Python
object as well as optimized communications of Python object exposing the
single-segment buffer interface (NumPy arrays, builtin bytes/string/array
objects).

This package contains %{name} compiled against Open MPI.


%package mpich2
BuildRequires:  mpich2-devel
Requires:       mpich2
Requires:       %{name}-common = %{version}-%{release}
Summary:        Python bindings of MPI, MPICH2 version
Provides:       mpi4py-runtime = %{version}-%{release}
%description mpich2
This package is constructed on top of the MPI-1/MPI-2 specification and
provides an object oriented interface which closely follows MPI-2 C++
bindings. It supports point-to-point (sends, receives) and collective
(broadcasts, scatters, gathers) communications of any picklable Python
object as well as optimized communications of Python object exposing the
single-segment buffer interface (NumPy arrays, builtin bytes/string/array
objects).

This package contains %{name} compiled against MPICH2.


%prep
%setup -q
# delete hidden file
rm docs/usrman/.buildinfo
# delete docs/source
# this is just needed to generate docs/*
rm -r docs/source

%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
%endif


%build
# Build parallel versions: set compiler variables to MPI wrappers
export CC=mpicc
export CXX=mpicxx

# Build OpenMPI version
%{_openmpi_load}
CFLAGS="%{optflags}" %{__python} setup.py build
mv build openmpi
%{_openmpi_unload}

# Build mpich2 version
%{_mpich2_load}
CFLAGS="%{optflags}" %{__python} setup.py build
mv build mpich2
%{_mpich2_unload}

%if 0%{?with_python3}
pushd %{py3dir}
# Build parallel versions: set compiler variables to MPI wrappers
export CC=mpicc
export CXX=mpicxx

# Build OpenMPI version
%{_openmpi_load}
CFLAGS="%{optflags}" %{__python3} setup.py build
mv build openmpi
%{_openmpi_unload}

# Build mpich2 version
%{_mpich2_load}
CFLAGS="%{optflags}" %{__python3} setup.py build
mv build mpich2
%{_mpich2_unload}

popd
%endif


%install
rm -rf %{buildroot}
# Install OpenMPI version
%{_openmpi_load}
mv openmpi build
%{__python} setup.py install -O1 --skip-build --root %{buildroot}
mkdir -p %{buildroot}%{python_sitearch}/openmpi
mv %{buildroot}%{python_sitearch}/%{name}/ %{buildroot}%{python_sitearch}/%{name}*.egg-info %{buildroot}%{python_sitearch}/openmpi
mv build openmpi
%{_openmpi_unload}

# Install MPICH2 version
%{_mpich2_load}
mv mpich2 build
%{__python} setup.py install -O1 --skip-build --root %{buildroot}
mkdir -p %{buildroot}%{python_sitearch}/mpich2
mv %{buildroot}%{python_sitearch}/%{name}/ %{buildroot}%{python_sitearch}/%{name}*.egg-info %{buildroot}%{python_sitearch}/mpich2
mv build mpich2
%{_mpich2_unload}


%if 0%{?with_python3}
pushd %{py3dir}
# Install OpenMPI version
%{_openmpi_load}
mv openmpi build
%{__python3} setup.py install -O1 --skip-build --root %{buildroot}
mkdir -p %{buildroot}%{python3_sitearch}/openmpi
mv %{buildroot}%{python3_sitearch}/%{name}/ %{buildroot}%{python3_sitearch}/%{name}*.egg-info %{buildroot}%{python3_sitearch}/openmpi
mv build openmpi
%{_openmpi_unload}

# Install MPICH2 version
%{_mpich2_load}
mv mpich2 build
%{__python3} setup.py install -O1 --skip-build --root %{buildroot}
mkdir -p %{buildroot}%{python3_sitearch}/mpich2
mv %{buildroot}%{python3_sitearch}/%{name}/ %{buildroot}%{python3_sitearch}/%{name}*.egg-info %{buildroot}%{python3_sitearch}/mpich2
mv build mpich2
%{_mpich2_unload}

popd
%endif


%check
# test openmpi?
%if 0%{?OPENMPI}
%{_openmpi_load}
PYTHONPATH=%{buildroot}%{python_sitearch}/openmpi \
    python test/runalltest.py
%{_openmpi_unload}
%endif

# test mpd?
%if 0%{?MPD}
%{_mpich2_load}

# create mpd.conf
export MPD_CONF_FILE=mpd.conf
echo MPD_SECRETWORD=$(pwgen -s 50 1) > mpd.conf
chmod 600 mpd.conf

mpd --daemon
PYTHONPATH=%{buildroot}%{python_sitearch}/mpich2 \
    python test/runalltest.py
mpdallexit

# delte mpd.conf again
rm mpd.conf
unset MPD_CONF_FILE


%{_mpich2_unload}
%endif

%if 0%{?with_python3}
# test openmpi?
%if 0%{?OPENMPI}
%{_openmpi_load}
PYTHONPATH=%{buildroot}%{python3_sitearch}/openmpi \
    python3 test/runalltest.py
%{_openmpi_unload}
%endif

# test mpd?
%if 0%{?MPD}
%{_mpich2_load}

# create mpd.conf
export MPD_CONF_FILE=mpd.conf
echo MPD_SECRETWORD=$(pwgen -s 50 1) > mpd.conf
chmod 600 mpd.conf

mpd --daemon
PYTHONPATH=%{buildroot}%{python3_sitearch}/mpich2 \
    python3 test/runalltest.py
mpdallexit

# delte mpd.conf again
rm mpd.conf
unset MPD_CONF_FILE

%{_mpich2_unload}
%endif # mpd disable
%endif # with_python3

%clean
rm -rf %{buildroot}


%files common
%defattr(-,root,root,-)
%doc HISTORY.txt LICENSE.txt

%files openmpi
%defattr(-,root,root,-)
%{python_sitearch}/openmpi/%{name}-%{version}-py?.?.egg-info
%{python_sitearch}/openmpi/%{name}

%files mpich2
%defattr(-,root,root,-)
%{python_sitearch}/mpich2/%{name}-%{version}-py?.?.egg-info
%{python_sitearch}/mpich2/%{name}

%if 0%{?with_python3}
%files -n python3-mpi4py-openmpi
%defattr(-,root,root,-)
%{python3_sitearch}/openmpi/%{name}-%{version}-py?.?.egg-info
%{python3_sitearch}/openmpi/%{name}

%files -n python3-mpi4py-mpich2
%defattr(-,root,root,-)
%{python3_sitearch}/mpich2/%{name}-%{version}-py?.?.egg-info
%{python3_sitearch}/mpich2/%{name}
%endif

%files docs
%defattr(-,root,root,-)
%doc docs/* demo


%changelog
* Fri Feb 25 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.2-7
- introduce OPENMPI and MPD macros to easy enable/disable the testsuite

* Tue Feb 16 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.2-6
- don't delete *.pyx/*.pyd
- delete docs/source

* Mon Feb  8 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.2-5
- disable testsuite

* Sun Feb  7 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.2-4
- enable testsuite
- move huge docs into docs subpackage

* Sun Feb  7 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.2-3
- delete lam building
- install to correct locations

* Sun Feb  7 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.2-2
- compile for different mpi versions

* Sun Feb  7 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.2-1
- initial import