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

%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
%global python3_version %(%{__python3} -c "import sys; sys.stdout.write(sys.version[:3])")

%{?filter_setup:
%filter_provides_in %{python_sitearch}.*\.so$
%filter_requires_in %{python_sitearch}/openmpi/mpi4py/lib-pmpi/lib.*\.so
%if 0%{?fedora} > 12 || 0%{?rhel} > 6
%filter_provides_in %{python3_sitearch}.*\.so$
%filter_requires_in %{python3_sitearch}/openmpi/mpi4py/lib-pmpi/lib.*\.so
%endif
%filter_setup
}

%global with_mpich 1
%if 0%{?rhel}
%ifarch ppc64
%global with_mpich 0
%endif
%endif

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

Name:           mpi4py
Version:        1.3
Release:        6%{?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
Provides:       python2-mpi4py = %{version}-%{release}
%if 0%{?with_python3}
BuildRequires:  python3-devel
%endif
Requires:       %{name}-common = %{version}-%{release}



%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, built-in bytes/string/array
objects).

%package docs
Summary:        Documentation for %{name}
Group:          Documentation
Requires:       %{name}-common = %{version}-%{release}
BuildArch:      noarch
%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, built-in 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, built-in bytes/string/array
objects).

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


%if %{with_mpich}
%package -n python3-mpi4py-mpich
BuildRequires:  mpich-devel
Requires:       mpich
Requires:       %{name}-common = %{version}-%{release}
Summary:        Python bindings of MPI, MPICH version
Provides:       python3-mpi4py-runtime = %{version}-%{release}
Provides:	python3-%{name}-mpich2 = %{version}-%{release}
Obsoletes:	python3-%{name}-mpich2 < 1.3-6
%description -n python3-mpi4py-mpich
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, built-in bytes/string/array
objects).

This package contains %{name} compiled against MPICH.
%endif
%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}
Provides:       python2-mpi4py-openmpi = %{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, built-in bytes/string/array
objects).

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


%if %{with_mpich}
%package mpich
BuildRequires:  mpich-devel
Requires:       mpich
Requires:       %{name}-common = %{version}-%{release}
Provides:       python2-mpi4py-mpich = %{version}-%{release}
Summary:        Python bindings of MPI, MPICH version
Provides:       mpi4py-runtime = %{version}-%{release}
Provides:	%{name}-mpich2 = %{version}-%{release}
Obsoletes:	%{name}-mpich2 < 1.3-6
%description mpich
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, built-in bytes/string/array
objects).

This package contains %{name} compiled against MPICH.
%endif


%prep
%setup -q
# delete docs/source
# this is just needed to generate docs/*
rm -r docs/source

# work around "wrong-file-end-of-line-encoding"
for file in $(find | grep runtests.bat); do
    sed -i 's/\r//' $file
done

%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}

%if %{with_mpich}
# Build mpich version
%{_mpich_load}
CFLAGS="%{optflags}" %{__python} setup.py build
mv build mpich
%{_mpich_unload}
%endif

%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}

%if %{with_mpich}
# Build mpich version
%{_mpich_load}
CFLAGS="%{optflags}" %{__python3} setup.py build
mv build mpich
%{_mpich_unload}
%endif

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}

%if %{with_mpich}
# Install MPICH version
%{_mpich_load}
mv mpich build
%{__python} setup.py install -O1 --skip-build --root %{buildroot}
mkdir -p %{buildroot}%{python_sitearch}/mpich
mv %{buildroot}%{python_sitearch}/%{name}/ %{buildroot}%{python_sitearch}/%{name}*.egg-info %{buildroot}%{python_sitearch}/mpich
mv build mpich
%{_mpich_unload}
%endif


%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}

%if %{with_mpich}
# Install MPICH version
%{_mpich_load}
mv mpich build
%{__python3} setup.py install -O1 --skip-build --root %{buildroot}
mkdir -p %{buildroot}%{python3_sitearch}/mpich
mv %{buildroot}%{python3_sitearch}/%{name}/ %{buildroot}%{python3_sitearch}/%{name}*.egg-info %{buildroot}%{python3_sitearch}/mpich
mv build mpich
%{_mpich_unload}
%endif

popd
%endif


%check
# test openmpi?
%if 0%{?OPENMPI}
%{_openmpi_load}
PYTHONPATH=%{buildroot}%{python_sitearch}/openmpi \
    mpiexec -np 1 python2 test/runtests.py
PYTHONPATH=%{buildroot}%{python_sitearch}/openmpi \
    mpiexec -np 5 python2 test/runtests.py
PYTHONPATH=%{buildroot}%{python_sitearch}/openmpi \
    mpiexec -np 8 python2 test/runtests.py
%{_openmpi_unload}
%endif

# test mpich?
%if 0%{?MPICH}
%if %{with_mpich}
%{_mpich_load}
PYTHONPATH=%{buildroot}%{python_sitearch}/mpich \
    mpiexec -np 1 python2 test/runtests.py
PYTHONPATH=%{buildroot}%{python_sitearch}/mpich \
    mpiexec -np 5 python2 test/runtests.py
PYTHONPATH=%{buildroot}%{python_sitearch}/mpich \
    mpiexec -np 8 python2 test/runtests.py
%{_mpich_unload}
%endif
%endif

%if 0%{?with_python3}
# test openmpi?
%if 0%{?OPENMPI}
%{_openmpi_load}
PYTHONPATH=%{buildroot}%{python3_sitearch}/openmpi \
    mpiexec -np 1 python3 test/runtests.py
PYTHONPATH=%{buildroot}%{python3_sitearch}/openmpi \
    mpiexec -np 5 python3 test/runtests.py
PYTHONPATH=%{buildroot}%{python3_sitearch}/openmpi \
    mpiexec -np 8 python3 test/runtests.py
%{_openmpi_unload}
%endif

# test mpich?
%if 0%{?MPICH}
%if %{with_mpich}
%{_mpich_load}
PYTHONPATH=%{buildroot}%{python3_sitearch}/mpich \
    mpiexec -np 1 python3 test/runtests.py
PYTHONPATH=%{buildroot}%{python3_sitearch}/mpich \
    mpiexec -np 5 python3 test/runtests.py
PYTHONPATH=%{buildroot}%{python3_sitearch}/mpich \
    mpiexec -np 8 python3 test/runtests.py
%{_mpich_unload}
%endif
%endif # mpich 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}

%if %{with_mpich}
%files mpich
%defattr(-,root,root,-)
%{python_sitearch}/mpich/%{name}-%{version}-py?.?.egg-info
%{python_sitearch}/mpich/%{name}
%endif

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

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

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


%changelog
* Wed Jul 24 2013 Deji Akingunola <dakingun@gmail.com> - 1.3-6
- Rename mpich2 sub-packages to mpich and rebuild for mpich-3.0

* Sat Aug  4 2012 Thomas Spura <tomspur@fedoraproject.org> - 1.3-5
- conditionalize mpich2 support, there is no mpich2 on el6-ppc64

* Fri Aug 03 2012 David Malcolm <dmalcolm@redhat.com> - 1.3-4
- rebuild for https://fedoraproject.org/wiki/Features/Python_3.3

* Fri Jul 20 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Wed Jan 25 2012 Thomas Spura <tomspur@fedoraproject.org> - 1.3-2
- filter requires in pysitearch/openmpi/mpi4py/lib-pmpi/lib (#741104)

* Fri Jan 20 2012 Thomas Spura <tomspur@fedoraproject.org> - 1.3-1
- update to 1.3
- filter provides in pythonsitearch
- run tests differently

* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.2-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Wed Mar 30 2011 Deji Akingunola <dakingun@gmail.com> - 1.2.2-6
- Rebuild for mpich2 soname bump

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Wed Dec 29 2010  David Malcolm <dmalcolm@redhat.com> - 1.2.2-4
- rebuild for newer python3

* Tue Oct 19 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.2.2-3
- rebuild for new mpich2 and openmpi versions

* Wed Sep 29 2010 jkeating - 1.2.2-2
- Rebuilt for gcc bug 634757

* Wed Sep 15 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.2.2-1
- update to new version

* Sun Aug 22 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.2.1-6
- rebuild with python3.2
  http://lists.fedoraproject.org/pipermail/devel/2010-August/141368.html

* Wed Jul 21 2010 David Malcolm <dmalcolm@redhat.com> - 1.2.1-5
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild

* Wed Jul  7 2010 Thomas Spura <tomspur@fedoreproject.org> - 1.2.1-4
- doc package needs to require common package, because of licensing

* Sun Apr 11 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.2.1-3
- also provides python2-mpi4py-*

* Sat Feb 27 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.2.1-2
- delete R on the main package in docs subpackage
  (main package is empty -> would be an unresolved dependency)

* Sat Feb 27 2010 Thomas Spura <tomspur@fedoraproject.org> - 1.2.1-1
- new version
- removing of hidden file not needed anymore (done upstream)
- fix spelling error builtin -> built-in

* Fri Feb 26 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