Blob Blame History Raw
%if 0%{?el6}
# Error: No Package found for mpich-devel on el6
ExcludeArch: ppc64
%endif

%if 0%{?fedora} >= 21 || 0%{?el7} || 0%{?el6}
%global blacs_libs 'mpiblacs'
%else
%global	blacs_libs 'mpiblacsCinit', 'mpiblacs'
%endif

%if 0%{?fedora} > 12
%global			with_python3	1
%endif

%global upstream_commit 7e8d3125fe2fd3d1064393d6ac181db6dd655a53

Name:			gpaw
Version:		1.1.0
Release:		24%{?dist}
Summary:		A grid-based real-space PAW method DFT code

License:		GPLv3+
URL:			https://wiki.fysik.dtu.dk/gpaw/
Source0:		https://gitlab.com/%{name}/%{name}/repository/archive.tar.gz?ref=%{version}#/%{name}-%{version}-%{upstream_commit}.tar.gz

BuildRequires:		time
BuildRequires:		libxc-devel
BuildRequires:		hdf5-devel
BuildRequires:		python2-devel
BuildRequires:		python-ase

%ifarch ppc64 s390x
BuildRequires:		atlas-devel
%else
BuildRequires:		openblas-devel
%endif

%if 0%{?with_python3}
BuildRequires:		python3-devel
BuildRequires:		python3-scipy
BuildRequires:		python3-ase
%endif # if with_python3

# no scipy on el6 ppc64
%if 0%{?el6}
%ifnarch ppc64
BuildRequires:		scipy
%endif
%else
BuildRequires:		scipy
%endif


BuildRequires:		%{name}-setups

Requires:		python-ase

Requires:		%{name}-common = %{version}-%{release}
Requires:		tar


%global desc_base \
GPAW is a density-functional theory (DFT) Python code based\
on the projector-augmented wave (PAW) method and the\
atomic simulation environment (ASE). It uses real-space uniform grids and\
multigrid methods or atom-centered basis-functions.

%description
%{desc_base}

%package openmpi
Summary:		%{name} - openmpi version
BuildRequires:		openssh-clients
BuildRequires:		openmpi-devel
BuildRequires:		scalapack-openmpi-devel
BuildRequires:		blacs-openmpi-devel
BuildRequires:		hdf5-openmpi-devel
Requires:		%{name} = %{version}-%{release}
Requires:		%{name}-common = %{version}-%{release}
%if 0%{?el6}
BuildRequires:		scalapack-openmpi
BuildRequires:		blacs-openmpi
BuildRequires:		hdf5-openmpi
%endif

%description openmpi
%{desc_base}

This package contains the openmpi version.

%package mpich
Summary:		%{name} - mpich version
BuildRequires:		mpich-devel
BuildRequires:		scalapack-mpich-devel
BuildRequires:		blacs-mpich-devel
BuildRequires:		hdf5-mpich-devel
Requires:		%{name} = %{version}-%{release}
Requires:		%{name}-common = %{version}-%{release}
%if 0%{?el6}
BuildRequires:		scalapack-mpich
BuildRequires:		blacs-mpich
BuildRequires:		hdf5-mpich
%endif

%description mpich
%{desc_base}

This package contains the mpich version.

%package common
Summary:		%{name} - common files
Requires:		%{name}-setups
BuildArch:		noarch

%description common
%{desc_base}

This package contains the common data files.


%if 0%{?with_python3}
%package -n python3-%{name}
Summary:		A grid-based real-space PAW method DFT code for Python 3
Requires:		python3-ase
Requires:		%{name}-common = %{version}-%{release}

%description -n python3-%{name}
%{desc_base}

%package -n python3-%{name}-openmpi
Summary:		python3-%{name} - openmpi version
BuildRequires:		openssh-clients
BuildRequires:		openmpi-devel
BuildRequires:		scalapack-openmpi-devel
BuildRequires:		blacs-openmpi-devel
BuildRequires:		hdf5-openmpi-devel
Requires:		python3-%{name} = %{version}-%{release}
Requires:		%{name}-common = %{version}-%{release}
%if 0%{?el6}
BuildRequires:		scalapack-openmpi
BuildRequires:		blacs-openmpi
BuildRequires:		hdf5-openmpi
%endif

%description -n python3-%{name}-openmpi
%{desc_base}

This package contains the openmpi Python 3 version.

%package -n python3-%{name}-mpich
Summary:		python3-%{name} - mpich version
BuildRequires:		mpich-devel
BuildRequires:		scalapack-mpich-devel
BuildRequires:		blacs-mpich-devel
BuildRequires:		hdf5-mpich-devel
Requires:		python3-%{name} = %{version}-%{release}
Requires:		%{name}-common = %{version}-%{release}
%if 0%{?el6}
BuildRequires:		scalapack-mpich
BuildRequires:		blacs-mpich
BuildRequires:		hdf5-mpich
%endif

%description -n python3-%{name}-mpich
%{desc_base}

This package contains the mpich Python 3 version.
%endif # with_python3


%prep
%setup -qTc -a 0
mv %{name}-%{version}-%{upstream_commit} python2
# do not link lapack when linking to openblas
sed -i "s/'openblas', 'lapack'/'openblas'/" python2/config.py
# if only libpython3.4.m.so instead of libpython3.4.so present http://legacy.python.org/dev/peps/pep-3149/
sed -i "s/' -lpython%s' % cfgDict\['VERSION'\]/' ' + cfgDict['BLDLIBRARY']/" python2/config.py
# revert Debian-centric naming of scalapack/blacs
sed -i "s/scalapack-openmpi/scalapack/" python2/customize.py
sed -i "s/blacsCinit-openmpi/scalapack/" python2/customize.py
sed -i "s/blacs-openmpi/scalapack/" python2/customize.py
cp -pr python2 python3
cp -p python2/LICENSE .

# fix the python version in the scripts
find python2/tools -type f | xargs sed -i '1s|^#!/usr/bin/env python.*|#!/usr/bin/env python2|'
find python3/tools -type f | xargs sed -i '1s|^#!/usr/bin/env python.*|#!/usr/bin/env python3|'


%build

# To avoid replicated code define a macro
%global dobuild() \
CFLAGS="$RPM_OPT_FLAGS" ${PYTHON} setup.py build && \
mv build build$MPI_SUFFIX && \
${PYTHON} setup.py clean

# build serial version (_gpaw.so/_gpaw_hdf5.so will be taken from it)
# disable scalapack
sed -i 's/# scalapack =.*/scalapack = False/' python2/customize.py
# enable hdf5
sed -i "s/.*hdf5 =.*/hdf5 = True; libraries += ['hdf5']/" python2/customize.py
echo "extra_compile_args += ['-fPIC']" >> python2/customize.py

%if 0%{?with_python3}
cp -pf python2/customize.py python3/customize.py
# disable hdf5
# build/temp.linux-x86_64-3.4/c/hdf5.o: In function `init_gpaw_hdf5':
# hdf5.c:(.text+0x1192): undefined reference to `Py_InitModule'
sed -i "s/.*hdf5 =.*/hdf5 = False/" python3/customize.py
pushd python3
MPI_SUFFIX=_serial PYTHON=%{__python3} %dobuild
popd
%endif # with _python3
pushd python2
MPI_SUFFIX=_serial PYTHON=%{__python} %dobuild
popd

# build openmpi version
%{_openmpi_load}
# enable scalapack
sed -i 's/.*scalapack =.*/scalapack = True/' python2/customize.py
sed -i "s/'scalapack'/%{blacs_libs}, 'scalapack'/" python2/customize.py
# enable parallel hdf5
sed -i "s|.*hdf5 =.*|hdf5 = True; import os; extra_link_args += [os.path.join(os.environ['MPI_LIB'], 'libhdf5.so')]|" python2/customize.py
# force mpicc
sed -i 's/# compiler =.*/compiler = "mpicc"/' python2/customize.py
%if 0%{?with_python3}
cp -pf python2/customize.py python3/customize.py
# build/temp.linux-x86_64-3.4/c/hdf5.o: In function `init_gpaw_hdf5':
# hdf5.c:(.text+0x1192): undefined reference to `Py_InitModule'
sed -i "s/.*hdf5 =.*/hdf5 = False/" python3/customize.py
pushd python3
PYTHON=%{__python3} %dobuild
popd
%endif # with _python3
pushd python2
PYTHON=%{__python} %dobuild
popd
%{_openmpi_unload}

# build mpich version
%{_mpich_load}
# enable scalapack
sed -i 's/.*scalapack =.*/scalapack = True/' python2/customize.py
sed -i "s/'scalapack'/%{blacs_libs}, 'scalapack'/" python2/customize.py
# enable parallel hdf5
sed -i "s|.*hdf5 =.*|hdf5 = True; import os; extra_link_args += [os.path.join(os.environ['MPI_LIB'], 'libhdf5.so')]|" python2/customize.py
# force mpicc
sed -i 's/# compiler =.*/compiler = "mpicc"/' python2/customize.py
%if 0%{?with_python3}
cp -pf python2/customize.py python3/customize.py
# build/temp.linux-x86_64-3.4/c/hdf5.o: In function `init_gpaw_hdf5':
# hdf5.c:(.text+0x1192): undefined reference to `Py_InitModule'
sed -i "s/.*hdf5 =.*/hdf5 = False/" python3/customize.py
pushd python3
PYTHON=%{__python3} %dobuild
popd
%endif # with _python3
pushd python2
PYTHON=%{__python} %dobuild
popd
%{_mpich_unload}


%install

# disable scalapack
sed -i 's/.*scalapack =.*/scalapack = False/' python2/customize.py
# disable mpicc
sed -i 's/compiler = "mpicc"/#compiler = "mpicc"/' python2/customize.py
# disable hdf5
sed -i "s|.*hdf5 =.*|#hdf5 = False|" python2/customize.py

# To avoid replicated code define a macro
%global doinstall() \
CFLAGS="$RPM_OPT_FLAGS" ${PYTHON} setup.py install --skip-build --prefix=$RPM_BUILD_ROOT%{_prefix}

%if 0%{?with_python3}
cp -pf python2/customize.py python3/customize.py
pushd python3
mv build_serial build
PYTHON=%{__python3} %doinstall
# rename scripts
for file in `find $RPM_BUILD_ROOT/%{_bindir}/ -name "gpaw*"`; do
  mv -f ${file} $RPM_BUILD_ROOT/%{_bindir}/`basename $file`3
done
popd
%endif # with _python3
pushd python2
mv build_serial build
PYTHON=%{__python} %doinstall
popd

# copy parallel executables
%global doinstall_executable() \
mkdir -p $RPM_BUILD_ROOT/$MPI_BIN&& \
install -p -m 755 build$MPI_SUFFIX/bin.*/%{name}-python $RPM_BUILD_ROOT/$MPI_BIN/%{name}-${PYTHON}$MPI_SUFFIX

# install openmpi version
%{_openmpi_load}
%if 0%{?with_python3}
pushd python3
PYTHON=python3 %doinstall_executable
popd
%endif # with _python3
pushd python2
PYTHON=python %doinstall_executable
popd
%{_openmpi_unload}

# install mpich version
%{_mpich_load}
%if 0%{?with_python3}
pushd python3
PYTHON=python3 %doinstall_executable
popd
%endif # with _python3
pushd python2
PYTHON=python %doinstall_executable
popd
%{_mpich_unload}

mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{name}

%check

export NPROC=4 # test on 4 cores (scalapack test needs that)

# To avoid replicated code define a macro
%global docheck() \
GPAW_PLATFORM=$($PYTHON -c "from distutils import util, sysconfig; print(util.get_platform()+'-'+sysconfig.get_python_version())")&& \
export PYTHONPATH=`pwd`/build/lib.${GPAW_PLATFORM} \
PATH=`pwd`/tools:${PATH} \
time $GPAW_EXECUTABLE `which gpaw-test` --range='linalg/gemm_complex.py,fileio/restart.py' --debug 2>&1 | tee gpaw-test${NPROC}$MPI_SUFFIX.log

# check serial version
%if 0%{?with_python3}
pushd python3
MPI_SUFFIX="" PYTHON="python3" GPAW_EXECUTABLE="python3" %docheck
popd
%endif # with _python3
pushd python2
MPI_SUFFIX="" PYTHON="python" GPAW_EXECUTABLE="python" %docheck
popd

# check openmpi version
%{_openmpi_load}
%if 0%{?with_python3}
pushd python3
PYTHON="python3" GPAW_EXECUTABLE="mpiexec -np ${NPROC} build$MPI_SUFFIX/bin.*/%{name}-python" %docheck
popd
%endif # with _python3
pushd python2
PYTHON="python" GPAW_EXECUTABLE="mpiexec -np ${NPROC} build$MPI_SUFFIX/bin.*/%{name}-python" %docheck
popd
%{_openmpi_unload}

# this will fail for mpich2 on el6 - mpd would need to be started ...
# check mpich version
%{_mpich_load}
%if 0%{?with_python3}
pushd python3
PYTHON="python3" GPAW_EXECUTABLE="mpiexec -np ${NPROC} build$MPI_SUFFIX/bin.*/%{name}-python" %docheck
popd
%endif # with _python3
pushd python2
PYTHON="python" GPAW_EXECUTABLE="mpiexec -np ${NPROC} build$MPI_SUFFIX/bin.*/%{name}-python" %docheck
popd
%{_mpich_unload}


%files
%{_bindir}/%{name}*
%{python_sitearch}/_%{name}*.so
%{python_sitearch}/%{name}
%{python_sitearch}/%{name}-%{version}-py*.egg-info
%if 0%{?with_python3}
%exclude %{_bindir}/%{name}*3
%endif


%files common
%doc LICENSE


%files openmpi
%{_libdir}/openmpi%{?_opt_cc_suffix}/bin/%{name}-python_openmpi


%files mpich
%{_libdir}/mpich%{?_opt_cc_suffix}/bin/%{name}-python_mpich


%if 0%{?with_python3}
%files -n python3-%{name}
%{_bindir}/%{name}*3
%{python3_sitearch}/_%{name}*.so
%{python3_sitearch}/%{name}
%{python3_sitearch}/%{name}-%{version}-py*.egg-info
%endif


%if 0%{?with_python3}
%files -n python3-%{name}-openmpi
%{_libdir}/openmpi%{?_opt_cc_suffix}/bin/%{name}-python3_openmpi
%endif


%if 0%{?with_python3}
%files -n python3-%{name}-mpich
%{_libdir}/mpich%{?_opt_cc_suffix}/bin/%{name}-python3_mpich
%endif


%changelog
* Wed Jul 13 2016 Peter Robinson <pbrobinson@fedoraproject.org> 1.1.0-24
- aarch64 has openblas now
- simplify arch conditionals

* Wed Jul  6 2016 Marcin Dulak <Marcin.Dulak@gmail.com> - 1.1.0-23
- gpaw-1.1.0

* Sat Jun 18 2016 Marcin Dulak <Marcin.Dulak@gmail.com> - 1.0.0-23
- upstream moved to gitlab, upstream update
- python3 package (bug #1323264)

* Thu Apr 21 2016 Susi Lehtola <jussilehtola@fedoraproject.org> - 0.11.0.13004-22
- Rebuild against libxc 3.0.0.

* Sat Feb 13 2016 Marcin Dulak <Marcin.Dulak@gmail.com> - 0.11.0.13004-21
- explicit Requires are needed for scalapack, blacs and hdf5 on el6 (bug #1301922)
- ppc64le needs -std=c99

* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.11.0.13004-20
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Thu Jan 21 2016 Orion Poplawski <orion@cora.nwra.com> - 0.11.0.13004-19
- Rebuild for hdf5 1.8.16

* Thu Dec 17 2015 Marcin Dulak <Marcin.Dulak@gmail.com> - 0.11.0.13004-18
- get rid of old mpich globals

* Mon Dec 14 2015 Yaakov Selkowitz <yselkowi@redhat.com> - 0.11.0.13004-17
- Fix build on aarch64 (#1291383)

* Wed Sep 16 2015 Orion Poplawski <orion@cora.nwra.com> - 0.11.0.13004-16
- Rebuild for openmpi 1.10.0

* Sun Jul 26 2015 Sandro Mani <manisandro@gmail.com> - 0.11.0.13004-15
- Rebuild for RPM MPI Requires Provides Change

* Wed Jul 22 2015 Marcin Dulak <Marcin.Dulak@gmail.com> - 0.11.0.13004-14
- upstream update
- files-attr

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.10.0.11364-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Thu May 21 2015 Marcin Dulak <Marcin.Dulak@gmail.com> - 0.10.0.11364-12
- mpi versions Require gpaw

* Sun May 17 2015 Orion Poplawski <orion@cora.nwra.com> - 0.10.0.11364-11
- Rebuild for hdf5 1.8.15

* Sun May  3 2015 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 0.10.0.11364-10
- Rebuild for changed mpich

* Wed Jan 07 2015 Orion Poplawski <orion@cora.nwra.com> - 0.10.0.11364-9
- Rebuild for hdf5 1.8.14

* Thu Nov 20 2014 Marcin Dulak <Marcin.Dulak@gmail.com> - 0.10.0.11364-8
- new style of linking blacs on EL6

* Thu Oct 23 2014 Marcin Dulak <Marcin.Dulak@gmail.com> - 0.10.0.11364-7
- mpich version 3 in EL6
- use atlas on aarch64
- ppc64 on EL7

* Sat Aug 16 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.10.0.11364-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Sat Jun 07 2014 Marcin Dulak <Marcin.Dulak@gmail.com> - 0.10.0.11364-5
- explicit Requires

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.10.0.11364-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Thu May 22 2014 Marcin Dulak <Marcin.Dulak@gmail.com> 0.10.0.11364-3
- consistent usage of RPM_BUILD_ROOT/RPM_OPT_FLAGS
- hdf5 enabled
- blacs-2.0.2 on fedora >= 21

* Fri May 2 2014 Marcin Dulak <Marcin.Dulak@gmail.com> 0.10.0.11364-2
- %%arm and ppc64 added
- more explicit globs in %%files
- gcc BR removed
- permissions of _gpaw.so fixed

* Tue Apr 8 2014 Marcin Dulak <Marcin.Dulak@gmail.com> 0.10.0.11364-1
- initial version for Fedora