0310a2e
# Use forge macros for getting source tarball from GitHub
0310a2e
%global forgeurl https://github.com/nest/nest-simulator
0310a2e
c9aab32
# We build the python bit separately - their build system doesn't let me build
c9aab32
# and install separately - everything is done at install time
c9aab32
c9aab32
# We do not build the developer documentation with doxygen. Advanced developers
c9aab32
# that develop based on the source git tree can build it themselves
bded264
c9aab32
# Switch them off if you want
dcac812
%bcond mpich 1
dcac812
%bcond openmpi 1
eb10d10
224e11f
# Tests include source linters and so on, and require a specific older version
224e11f
# of vera and clang and so forth, so we simply rely on upstream CI here
dcac812
%bcond tests 0
c9aab32
90ec03a
# Default for numthreads
90ec03a
%global numthreads %{?_smp_build_ncpus}
90ec03a
049081a
# build fails on ppc with lto enabled in rawhide
2e59188
# https://bugzilla.redhat.com/show_bug.cgi?id=2056459
049081a
# fails on F34 and F35 on aarch64
049081a
%ifarch %{power64} %{arm64}
2e59188
%global _lto_cflags %{nil}
2e59188
%endif
2e59188
90ec03a
# On armv7 we get a failure with LTO.  The log has no useful information in it
90ec03a
# but my guess is we ran out of memory on the builder.  Disable LTO for armv7
cae1b7e
# Also runs out of memory without lto. Seems to need about 25Gigs per thread,
90ec03a
# so limit the number of threads
2e59188
90ec03a
%ifarch armv7hl
90ec03a
%global _lto_cflags %{nil}
90ec03a
cae1b7e
%global numthreads %(awk '/MemTotal:/ {print int($2/25e6)}' /proc/meminfo)
90ec03a
90ec03a
%if 0%{numthreads} > 0%{?_smp_build_ncpus}
90ec03a
%global numthreads %{?_smp_build_ncpus}
90ec03a
%endif
90ec03a
90ec03a
# ensure that it's > 0
90ec03a
%if 0%{numthreads} == 0
90ec03a
%global numthreads 1
90ec03a
%endif
90ec03a
cae1b7e
# also reduce debuginfo level
e588c05
%global optflags %(echo "%optflags" | sed  -e 's/-g /-g1 /')
cae1b7e
%endif
5c9b4b3
c9aab32
Name:           nest
c9c07c7
Version:        3.7
9f26967
Release:        %autorelease
c9aab32
Summary:        The neural simulation tool
0310a2e
%forgemeta
c9aab32
a8cb2ee
# thirdparty/compose is LGPLv2.1+
a8cb2ee
# thirdparty/randutils.hpp is MIT
e79a42f
# SPDX
e79a42f
License:        GPL-2.0-or-later and MIT and LGPL-2.1-or-later
c9aab32
URL:            http://www.nest-simulator.org/
0310a2e
Source0:        %forgesource
52613e7
Source1:        README-Fedora.md
c9aab32
c9c07c7
# https://github.com/sanjayankur31/nest-simulator/tree/fedora-3.7
ef85260
# 1. Let it build and install the cythonised shared object But we still build
ef85260
# our python modules ourselves
c9aab32
ef85260
# 2. The helpindex must be generated after the help files have been installed
ef85260
# to the install location, so we do this manually because the script doesn't
c9aab32
# respect rpmbuildroot and so on
c9c07c7
Patch:          0001-disable-python-setups.patch
a8cb2ee
# Tweak PYEXECDIR
c9c07c7
Patch:          0002-tweak-PYEXECDIR.patch
a8cb2ee
# Use system Random123
c9c07c7
Patch:          0003-use-system-Random123.patch
e7b6b21
# Remove rpath
c9c07c7
Patch:          0004-remove-rpath.patch
bded264
# Install in standard libdir
c9c07c7
Patch:          0005-install-in-libdir.patch
bded264
# Use online docs for helpdesk
c9c07c7
Patch:          0006-use-online-documentation.patch
ef85260
ab0387d
# Remove hard coded O0
ab0387d
Patch:          0007-remove-hard-coded-O0.patch
ab0387d
6c5e89e
# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
6c5e89e
ExcludeArch:    %{ix86}
6c5e89e
a8cb2ee
BuildRequires:  boost-devel
c9aab32
BuildRequires:  cmake
e7b6b21
BuildRequires:  chrpath
c9aab32
BuildRequires:  graphviz
c9aab32
BuildRequires:  gcc-c++
a8cb2ee
BuildRequires:  make
a8cb2ee
BuildRequires:  ncurses-devel
a8cb2ee
BuildRequires:  gsl-devel
a8cb2ee
BuildRequires:  libtool
a8cb2ee
BuildRequires:  libtool-ltdl-devel
224e11f
BuildRequires:  libneurosim-devel
a8cb2ee
BuildRequires:  python3-devel
a8cb2ee
BuildRequires:  python3-Cython
ef61101
BuildRequires:  python3-mock
a8cb2ee
BuildRequires:  python3-pytest
bac4234
BuildRequires:  python3-setuptools
a8cb2ee
BuildRequires:  readline-devel
a8cb2ee
BuildRequires:  Random123-devel
c9aab32
Requires:       %{name}-common
c9aab32
ef85260
%global _description %{expand:
ef85260
NEST is a simulator for spiking neural network models that focuses on the
ef85260
dynamics, size and structure of neural systems rather than on the exact
ef85260
morphology of individual neurons. The development of NEST is coordinated by the
ef85260
NEST Initiative.  NEST is ideal for networks of spiking neurons of any size,
ef85260
for example: Models of information processing e.g. in the visual or auditory
ef85260
cortex of mammals; Models of network activity dynamics, e.g. laminar cortical
ef85260
networks or balanced random networks; Models of learning and plasticity.
ef85260
Please read the README-Fedora.md file provided in each package for information
ef85260
on how these NEST packages are to be used.
ef85260
bded264
Please see https://nest-simulator.readthedocs.io/ for the latest documentation.
ef85260
}
c9aab32
ef85260
%description %_description
c9aab32
c9aab32
%package common
c9aab32
BuildArch:  noarch
c9aab32
Summary:    Common files for %{name}
c9aab32
ef85260
%description common %_description
c9aab32
f31f0b8
# These are also arch specific
5ba34ea
%package devel
5ba34ea
Summary:    Development files for %{name}
5ba34ea
Requires:   %{name}%{?_isa} = %{version}-%{release}
cb7e44a
5ba34ea
# provide headers package
5ba34ea
Provides:   %{name}-headers%{?_isa} = %{version}-%{release}
5ba34ea
5ba34ea
%description devel %_description
cb7e44a
c9aab32
%package doc
c9aab32
BuildArch:  noarch
c9aab32
Summary:    Documentation for %{name}
c9aab32
ef85260
%description doc %_description
c9aab32
c9aab32
c9aab32
%package -n python3-%{name}
c9aab32
Summary:    Python3 bindings for nest
c9aab32
Requires:   %{name} = %{version}-%{release}
c9aab32
Requires:   %{name}-common = %{version}-%{release}
798ca49
Requires:   %{py3_dist numpy} %{py3_dist scipy}
798ca49
Recommends: %{py3_dist matplotlib}
798ca49
Recommends: %{py3_dist ipython}
c9aab32
%{?python_provide:%python_provide python3-%{name}}
c9aab32
ef85260
%description -n python3-%{name} %_description
c9aab32
224e11f
%if %{with openmpi}
c9aab32
%package openmpi
c9aab32
Summary:        %{name} built with openmpi
c9aab32
BuildRequires:  openmpi-devel
c9aab32
BuildRequires:  rpm-mpi-hooks
224e11f
BuildRequires:  libneurosim-openmpi-devel
d1e0752
BuildRequires:  MUSIC-openmpi-devel
d1e0752
BuildRequires:  MUSIC-openmpi
c9aab32
Requires:       openmpi
c9aab32
Requires:       %{name}-openmpi-common = %{version}-%{release}
c9aab32
ef85260
%description openmpi %_description
c9aab32
c9aab32
%package openmpi-common
c9aab32
Summary:    Common files for %{name} built with openmpi support
c9aab32
ef85260
%description openmpi-common %_description
c9aab32
5ba34ea
%package openmpi-devel
5ba34ea
Summary:    Development files for %{name} built with openmpi support
5ba34ea
Requires:   %{name}-openmpi%{?_isa} = %{version}-%{release}
5ba34ea
5ba34ea
# provide headers package
5ba34ea
Provides:   %{name}-openmpi-headers%{?_isa} = %{version}-%{release}
cb7e44a
5ba34ea
%description openmpi-devel %_description
c9aab32
c9aab32
%package -n python3-%{name}-openmpi
c9aab32
Summary:    Python3 bindings for nest with openmpi support
c9aab32
BuildRequires:  rpm-mpi-hooks
c9aab32
Requires:   openmpi
c9aab32
Requires:   %{name}-openmpi = %{version}-%{release}
c9aab32
Requires:   %{name}-openmpi-common = %{version}-%{release}
798ca49
Requires:   %{py3_dist numpy} %{py3_dist scipy}
798ca49
Recommends: %{py3_dist matplotlib}
798ca49
Recommends: %{py3_dist ipython}
c9aab32
%{?python_provide:%python_provide python3-%{name}-openmpi}
c9aab32
ef85260
%description -n python3-%{name}-openmpi %_description
c9aab32
%endif
c9aab32
224e11f
%if %{with mpich}
c9aab32
%package mpich
c9aab32
Summary:        %{name} built with mpich
c9aab32
BuildRequires:  mpich-devel
c9aab32
BuildRequires:  rpm-mpi-hooks
224e11f
BuildRequires:  libneurosim-mpich-devel
d1e0752
BuildRequires:  MUSIC-mpich-devel
d1e0752
BuildRequires:  MUSIC-mpich
c9aab32
Requires:       mpich
c9aab32
Requires:       %{name}-mpich-common = %{version}-%{release}
c9aab32
ef85260
%description mpich %_description
c9aab32
c9aab32
%package mpich-common
c9aab32
Summary:    Common files for %{name} built with mpich support
c9aab32
ef85260
%description mpich-common %_description
c9aab32
5ba34ea
%package mpich-devel
cb7e44a
Summary:    Header files for %{name} built with mpich support
5ba34ea
Requires:   %{name}-mpich%{?_isa} = %{version}-%{release}
5ba34ea
5ba34ea
# provide headers package
5ba34ea
Provides:   %{name}-mpich-headers%{?_isa} = %{version}-%{release}
cb7e44a
5ba34ea
%description mpich-devel %_description
cb7e44a
cb7e44a
c9aab32
%package -n python3-%{name}-mpich
c9aab32
Summary:    Python3 bindings for nest with mpich support
c9aab32
BuildRequires:  rpm-mpi-hooks
c9aab32
Requires:   %{name}-mpich = %{version}-%{release}
c9aab32
Requires:   %{name}-mpich-common = %{version}-%{release}
c9aab32
Requires:   mpich
798ca49
Requires:   %{py3_dist numpy} %{py3_dist scipy}
798ca49
Recommends: %{py3_dist matplotlib}
798ca49
Recommends: %{py3_dist ipython}
c9aab32
%{?python_provide:%python_provide python3-%{name}-mpich}
c9aab32
ef85260
%description -n python3-%{name}-mpich %_description
c9aab32
%endif
c9aab32
c9aab32
%prep
1d58476
%forgeautosetup -p1
52613e7
cp %{SOURCE1} ./ -v
c9aab32
c9c07c7
# Fix VERSION
c9c07c7
# TODO: Check if needed with each release
4d19d9c
echo %{version} > VERSION
4d19d9c
c9c07c7
eb10d10
# Tweaks
c9aab32
# We'll set it ourselves - easier for mpi implementations
c9aab32
sed -i.orig '/PYEXECDIR/ d' cmake/ProcessOptions.cmake
c9aab32
# These files are all in standard locations so we don't need them
c9aab32
# Loading an MPI module sets up PATH correctly
e588c05
sed -i '/PATH=/ d' bin/nest_vars.sh.in
5ba34ea
# correct output of --libs in nest-config
5ba34ea
# it does not need $prefix there
e588c05
sed -i 's|-L$prefix/|-L|' bin/nest-config.in
a8cb2ee
# Delete bundled Random123 copy
a8cb2ee
rm -rf thirdparty/Random123
c9aab32
52613e7
# Correct shebangs for py3
0f58ad3
find . -name "*.py" -exec sed -i 's|#!/usr/bin/env python.*|#!/usr/bin/python3|' '{}' \;
0f58ad3
0f58ad3
# builddir for serial
0f58ad3
mkdir build-serial
cb7e44a
224e11f
%if %{with mpich}
0f58ad3
    mkdir build-mpich
c9aab32
%endif
c9aab32
224e11f
%if %{with openmpi}
0f58ad3
    mkdir build-openmpi
c9aab32
%endif
c9aab32
0f58ad3
c9aab32
%build
5b4624a
c9aab32
%global do_cmake_config \
c9aab32
echo  \
0f58ad3
echo "*** BUILDING %{name}$MPI_COMPILE_TYPE ***"  \
52613e7
export PYEXECDIR=$MPI_SITEARCH  \
224e11f
%set_build_flags \
5c9b4b3
echo  \
0f58ad3
pushd build$MPI_COMPILE_TYPE  && \
c9aab32
    cmake \\\
c9aab32
        -DCMAKE_C_FLAGS_RELEASE:STRING="-DNDEBUG" \\\
c9aab32
        -DCMAKE_CXX_FLAGS_RELEASE:STRING="-DNDEBUG" \\\
c9aab32
        -DCMAKE_Fortran_FLAGS_RELEASE:STRING="-DNDEBUG" \\\
c9aab32
        -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \\\
99131e2
        -DCMAKE_INSTALL_INCLUDEDIR:PATH=$MPI_INCLUDE \\\
99131e2
        -DCMAKE_INSTALL_LIBDIR:PATH=$MPI_LIB \\\
c9aab32
        -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\
a8cb2ee
        -DSHARE_INSTALL_PREFIX:PATH=%{_prefix} \\\
5c9b4b3
        -Dwith-optimize:BOOL=OFF \\\
c9aab32
        -DCMAKE_SKIP_RPATH:BOOL=ON \\\
eed5430
        -DCMAKE_SKIP_BUILD_RPATH:BOOL=ON \\\
eed5430
        -DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON \\\
e7b6b21
        -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF \\\
c9aab32
        -Dwith-mpi:BOOL=$MPI_YES \\\
c9aab32
        -Dwith-gsl:BOOL=ON \\\
5c9b4b3
        -Dwith-boost:BOOL=ON \\\
224e11f
        -Dwith-libneurosim:PATH=$MPI_HOME \\\
a8cb2ee
        -Dwith-python:BOOL=ON  \\\
c9aab32
        -DPYEXECDIR:PATH=$MPI_SITEARCH \\\
c9aab32
        -DCMAKE_INSTALL_PREFIX:PATH=$MPI_HOME \\\
c9aab32
        -DBUILD_SHARED_LIBS:BOOL=ON \\\
a8cb2ee
        -DPY_MPI4PY:PATH=$PY_MPI4PY \\\
a8cb2ee
        -DHAVE_RANDOM_123:BOOL=ON \\\
d1e0752
%if %{music} \
d1e0752
        -Dwith-music:BOOL=ON \\\
90ec03a
        -DMUSIC_INCLUDE_DIR:PATH=$MPI_INCLUDE \\\
d1e0752
        -DMUSIC_LIBRARY:PATH=$MPI_LIB/libmusic.so \\\
d1e0752
        -DMUSIC_EXECUTABLE:PATH=$MPI_BIN/music$MPI_SUFFIX \\\
d1e0752
%else \
d1e0752
        -Dwith-music:BOOL=OFF \\\
d1e0752
%endif \
c9aab32
%if "%{_lib}" == "lib64" \
0f58ad3
        -DLIB_SUFFIX=64 .. && \
c9aab32
%else                      \
0f58ad3
        -DLIB_SUFFIX="" .. && \
c9aab32
%endif \
c9aab32
popd || exit -1;
c9aab32
c9aab32
%global do_make_build \
0f58ad3
    %make_build -j%{numthreads} -C build$MPI_COMPILE_TYPE || exit -1
c9aab32
c9aab32
%global do_pybuild \
0f58ad3
pushd build$MPI_COMPILE_TYPE  && \
c9aab32
    pushd pynest && \
4d19d9c
        # Create nest/lib dir manually or build fails \
4d19d9c
        mkdir nest/lib \
aa9566f
        $PYTHON_BIN setup.py build \
c9aab32
    popd && \
c9aab32
popd || exit -1;
c9aab32
c9aab32
# Build serial version, dummy arguments
d1e0752
# Disable music, which requires MPI to be ON
d1e0752
%global music 0
c9aab32
export MPI_PYTHON3_SITEARCH="%{python3_sitearch}"
c9aab32
export MPI_COMPILER=serial
c9aab32
export MPI_SUFFIX=""
c9aab32
export MPI_HOME=%{_prefix}
c9aab32
export MPI_BIN=%{_bindir}
99131e2
export MPI_INCLUDE=%{_includedir}
99131e2
export MPI_LIB=%{_libdir}
c9aab32
export MPI_YES=OFF
a8cb2ee
export PY_MPI4PY=OFF
c9aab32
# Python 3
0f58ad3
export MPI_COMPILE_TYPE="-serial"
c9aab32
export PYTHON_VERSION="3"
eed5430
export PYTHON_BIN="%{python3}"
c9aab32
export MPI_SITEARCH=$MPI_PYTHON3_SITEARCH
c9aab32
%{do_cmake_config}
c9aab32
%{do_make_build}
c9aab32
%{do_pybuild}
c9aab32
4d19d9c
# (1) Change configuration slightly for the MPI builds, We want the stuff
4d19d9c
# from doc/, examples/, and testsuite/ dirs only in the serial build.
4d19d9c
# Backup CMakeLists.txt since we need to put it back for installation
4d19d9c
# or nest_serial and nest_indirect will not be installed.
4d19d9c
# Don't generate docs for MPI builds
4d19d9c
# Don't install examples and extras for MPI builds
4d19d9c
# Don't install tests in docdir either for MPI builds
4d19d9c
sed -i.serial \
4d19d9c
-e '/add_subdirectory.*doc/ d' \
4d19d9c
-e '/add_subdirectory.*examples/ d' \
4d19d9c
-e '/add_subdirectory.*testsuite/ d' CMakeLists.txt
4d19d9c
d1e0752
# Enable music support
d1e0752
%global music 1
52613e7
# Build mpich version
224e11f
%if %{with mpich}
52613e7
%{_mpich_load}
52613e7
export CC=mpicc
52613e7
export CXX=mpicxx
52613e7
export FC=mpif90
52613e7
export F77=mpif77
52613e7
export MPI_YES=ON
c9aab32
# Python 3
52613e7
export MPI_COMPILE_TYPE="-mpich"
c9aab32
export PYTHON_VERSION="3"
eed5430
export PYTHON_BIN="%{python3}"
c9aab32
export MPI_SITEARCH=$MPI_PYTHON3_SITEARCH
a8cb2ee
export PY_MPI4PY=$MPI_PYTHON3_SITEARCH/mpi4py
c9aab32
%{do_cmake_config}
c9aab32
%{do_make_build}
c9aab32
%{do_pybuild}
c9aab32
c9aab32
%{_mpich_unload}
c9aab32
%endif
c9aab32
c9aab32
# Build OpenMPI version
4d19d9c
# Disable MUSIC support. OpenMPI build fails with MUSIC enabled.
4d19d9c
%global music 0
224e11f
%if %{with openmpi}
c9aab32
%{_openmpi_load}
c9aab32
export CC=mpicc
c9aab32
export CXX=mpicxx
c9aab32
export FC=mpif90
c9aab32
export F77=mpif77
c9aab32
export MPI_YES=ON
c9aab32
# Python 3
52613e7
export MPI_COMPILE_TYPE="-openmpi"
c9aab32
export PYTHON_VERSION="3"
eed5430
export PYTHON_BIN="%{python3}"
c9aab32
export MPI_SITEARCH=$MPI_PYTHON3_SITEARCH
a8cb2ee
export PY_MPI4PY=$MPI_PYTHON3_SITEARCH/mpi4py
c9aab32
%{do_cmake_config}
c9aab32
%{do_make_build}
c9aab32
%{do_pybuild}
c9aab32
c9aab32
%{_openmpi_unload}
c9aab32
%endif
c9aab32
c9aab32
%install
52613e7
# Install everything
c9aab32
%global do_install \
c9aab32
echo  \
0f58ad3
echo "*** INSTALLING %{name}$MPI_COMPILE_TYPE ***"  \
c9aab32
echo  \
0f58ad3
    %make_install -C build$MPI_COMPILE_TYPE || exit -1
c9aab32
c9aab32
52613e7
# Install the other python bits
c9aab32
%global do_pyinstall \
0f58ad3
pushd build$MPI_COMPILE_TYPE && \
c9aab32
    pushd pynest && \
c9aab32
        $PYTHON_BIN setup.py install --skip-build --root $RPM_BUILD_ROOT --install-lib=$MPI_SITEARCH && \
c9aab32
    popd && \
c9aab32
popd || exit -1;
c9aab32
c9aab32
4d19d9c
# (2) Put the original CMakeLists.txt back into place for installation
4d19d9c
mv -v CMakeLists.txt CMakeLists.txt.mpi
4d19d9c
mv -v CMakeLists.txt.serial CMakeLists.txt
4d19d9c
c9aab32
# install serial version
c9aab32
export MPI_SUFFIX=""
c9aab32
export MPI_HOME=%{_prefix}
c9aab32
export MPI_BIN=%{_bindir}
c9aab32
export MPI_YES=OFF
c9aab32
# Python 3
0f58ad3
export MPI_COMPILE_TYPE="-serial"
c9aab32
export MPI_SITEARCH="%{python3_sitearch}"
eed5430
export PYTHON_BIN="%{python3}"
52613e7
%{do_install}
c9aab32
%{do_pyinstall}
c9aab32
4d19d9c
# (3) Swap again for MPI installations
4d19d9c
mv -v CMakeLists.txt CMakeLists.txt.serial
4d19d9c
mv -v CMakeLists.txt.mpi CMakeLists.txt
4d19d9c
52613e7
# Install MPICH version
224e11f
%if %{with mpich}
52613e7
%{_mpich_load}
c9aab32
# Python 3
52613e7
export MPI_COMPILE_TYPE="-mpich"
c9aab32
export MPI_SITEARCH=$MPI_PYTHON3_SITEARCH
eed5430
export PYTHON_BIN="%{python3}"
52613e7
%{do_install}
52613e7
%{do_pyinstall}
c9aab32
c9aab32
# Remove duplicated docs
c9aab32
rm -rf $RPM_BUILD_ROOT/%{_libdir}/mpich/share/doc/%{name}
c9aab32
# Remove unneeded scripts
e588c05
rm -rf $RPM_BUILD_ROOT/%{_libdir}/mpich/share/%{name}/{slihelp_generator}
c9aab32
b6af78e
# Rename binaries to add MPI suffix
b6af78e
pushd $RPM_BUILD_ROOT/$MPI_BIN/
b6af78e
    mv -v %{name}{,$MPI_SUFFIX}
a8cb2ee
    mv -v %{name}-server{,$MPI_SUFFIX}
a8cb2ee
    mv -v %{name}-server-mpi{,$MPI_SUFFIX}
b6af78e
    mv -v %{name}_vars{,$MPI_SUFFIX}.sh
b6af78e
    mv -v %{name}-config{,$MPI_SUFFIX}
b6af78e
    mv -v sli{,$MPI_SUFFIX}
b6af78e
popd
b6af78e
e7b6b21
# Remove rpath
e7b6b21
chrpath --delete $RPM_BUILD_ROOT/$MPI_PYTHON3_SITEARCH/nest/pynestkernel.so
e7b6b21
chrpath --delete $RPM_BUILD_ROOT/$MPI_BIN/sli_mpich
e7b6b21
chrpath --delete $RPM_BUILD_ROOT/$MPI_BIN/nest_mpich
bded264
chrpath --delete $RPM_BUILD_ROOT/$MPI_LIB/libsli_readline.so
bded264
chrpath --delete $RPM_BUILD_ROOT/$MPI_LIB/libsli.so
bded264
chrpath --delete $RPM_BUILD_ROOT/$MPI_LIB/libnest.so
e7b6b21
c9aab32
%{_mpich_unload}
c9aab32
%endif
c9aab32
c9aab32
# Install OpenMPI version
224e11f
%if %{with openmpi}
c9aab32
%{_openmpi_load}
c9aab32
# Python 3
52613e7
export MPI_COMPILE_TYPE="-openmpi"
c9aab32
export MPI_SITEARCH=$MPI_PYTHON3_SITEARCH
eed5430
export PYTHON_BIN="%{python3}"
52613e7
%{do_install}
52613e7
%{do_pyinstall}
c9aab32
c9aab32
# Remove duplicated docs
c9aab32
rm -rf $RPM_BUILD_ROOT/%{_libdir}/openmpi/share/doc/%{name}
52613e7
# Correct doc location
52613e7
sed -i 's|NEST_DOC_DIR=$NEST_INSTALL_DIR/share/doc/nest|NEST_DOC_DIR=/usr/share/doc/nest/|' $RPM_BUILD_ROOT/$MPI_BIN/nest_vars.sh
c9aab32
# Remove duplicated scripts
e588c05
rm -rf $RPM_BUILD_ROOT/%{_libdir}/openmpi/share/%{name}/{slihelp_generator}
c9aab32
b6af78e
# Rename binaries to add MPI suffix
b6af78e
pushd $RPM_BUILD_ROOT/$MPI_BIN/
b6af78e
    mv -v %{name}{,$MPI_SUFFIX}
a8cb2ee
    mv -v %{name}-server{,$MPI_SUFFIX}
a8cb2ee
    mv -v %{name}-server-mpi{,$MPI_SUFFIX}
b6af78e
    mv -v %{name}_vars{,$MPI_SUFFIX}.sh
b6af78e
    mv -v %{name}-config{,$MPI_SUFFIX}
b6af78e
    mv -v sli{,$MPI_SUFFIX}
b6af78e
popd
e7b6b21
e7b6b21
# Remove rpath
e7b6b21
chrpath --delete $RPM_BUILD_ROOT/$MPI_PYTHON3_SITEARCH/nest/pynestkernel.so
e7b6b21
chrpath --delete $RPM_BUILD_ROOT/$MPI_BIN/sli_openmpi
e7b6b21
chrpath --delete $RPM_BUILD_ROOT/$MPI_BIN/nest_openmpi
bded264
chrpath --delete $RPM_BUILD_ROOT/$MPI_LIB/libsli_readline.so
bded264
chrpath --delete $RPM_BUILD_ROOT/$MPI_LIB/libsli.so
bded264
chrpath --delete $RPM_BUILD_ROOT/$MPI_LIB/libnest.so
e7b6b21
c9aab32
%{_openmpi_unload}
c9aab32
%endif
c9aab32
bded264
# Remove test suite so that it isn't included in the package
bded264
rm -rf $RPM_BUILD_ROOT/%{_datadir}/nest/testsuite/
bded264
rm -rf $RPM_BUILD_ROOT/%{_bindir}/run_all_cpptests
bded264
bded264
%if %{with mpich}
bded264
%{_mpich_load}
bded264
rm -rf $RPM_BUILD_ROOT/$MPI_HOME/share/nest/testsuite/
bded264
%{_mpich_unload}
bded264
%endif
bded264
%if %{with openmpi}
bded264
%{_openmpi_load}
bded264
rm -rf $RPM_BUILD_ROOT/$MPI_HOME/share/nest/testsuite/
bded264
%{_openmpi_unload}
bded264
%endif
a8cb2ee
c9aab32
%check
bded264
# Cannot run py3_check_import because importing nest does not work in a chroot,
bded264
# and there's no way to tweak the location it searches (/usr/share/nest/) to
bded264
# include the buildroot before invoking it. Previously, it listened to
bded264
# environment variables, but that seems to have been removed in v3. So we'll
bded264
# need to build, then install the rpms and then test import :/
bded264
# See sli/slistartup.cc
bded264
bded264
# upstream tests
bded264
%if %{with tests}
a8cb2ee
%global do_tests_3 \
c9aab32
echo  \
0f58ad3
echo "*** TESTING %{name}$MPI_COMPILE_TYPE ***"  \
c9aab32
echo  \
e588c05
PATH=$RPM_BUILD_ROOT/$NEST_BINDIR/:$PATH $RPM_BUILD_ROOT/$NEST_DATA_DIR/testsuite/do_tests.sh --source-dir=SKIP \
a8cb2ee
%{pytest} $NEST_PYTHONDIR/nest/tests
c9aab32
c9aab32
0f58ad3
export MPI_COMPILE_TYPE="-serial"
c9aab32
export NEST_BINDIR="%{_bindir}"
c9aab32
export PYTHON_VERSION="3"
eed5430
export PYTHON_BIN="%{python3}"
c9aab32
export NEST_PYTHONDIR=%{python3_sitearch}
c9aab32
%{do_tests_3}
c9aab32
52613e7
# Test mpich version
224e11f
%if %{with mpich}
c9aab32
%{_mpich_load}
52613e7
export MPI_COMPILE_TYPE="-mpich"
c9aab32
export NEST_BINDIR=$MPI_BIN
c9aab32
export NEST_PYTHONDIR=$MPI_PYTHON3_SITEARCH
c9aab32
export PYTHON_VERSION="3"
eed5430
export PYTHON_BIN="%{python3}"
c9aab32
%{do_tests_3}
c9aab32
c9aab32
%{_mpich_unload}
c9aab32
%endif
c9aab32
52613e7
# Test OpenMPI version
224e11f
%if %{with openmpi}
c9aab32
%{_openmpi_load}
52613e7
export MPI_COMPILE_TYPE="-openmpi"
c9aab32
export PYTHON_VERSION="3"
eed5430
export PYTHON_BIN="%{python3}"
c9aab32
export MPI_SITEARCH=$MPI_PYTHON3_SITEARCH
c9aab32
%{do_tests_3}
c9aab32
c9aab32
%{_openmpi_unload}
c9aab32
%endif
c9aab32
%endif
c9aab32
af69da9
# remove LICENSE file from docs
af69da9
rm -v %{buildroot}/%{_pkgdocdir}/LICENSE
eed5430
eed5430
c9aab32
%files
c9aab32
%license LICENSE
a8cb2ee
%doc README-Fedora.md SECURITY.md ACKNOWLEDGMENTS.md README.md CHANGES CONTRIBUTING.md
c9aab32
%{_bindir}/%{name}
a8cb2ee
%{_bindir}/%{name}-server
a8cb2ee
%{_bindir}/%{name}-server-mpi
c9aab32
%{_bindir}/sli
c9aab32
%{_bindir}/%{name}_vars.sh
c9aab32
%{_bindir}/%{name}-config
c9aab32
%{_bindir}/%{name}_serial
c9aab32
%{_bindir}/%{name}_indirect
bded264
%{_libdir}/*.so.3*
c9aab32
c9aab32
%files common
bded264
%license LICENSE
c9aab32
%{_datadir}/%{name}
c9aab32
5ba34ea
%files devel
cb7e44a
%{_includedir}/%{name}
bded264
%{_libdir}/*.so
cb7e44a
c9aab32
%files doc
bded264
%license LICENSE
af69da9
%doc %{_pkgdocdir}/EditorSupport
af69da9
%doc %{_pkgdocdir}/examples
af69da9
%doc %{_pkgdocdir}/run_examples.sh
c9aab32
c9aab32
%files -n python3-%{name}
c9aab32
%{python3_sitearch}/%{name}
a8cb2ee
%{python3_sitearch}/nest_simulator-%{version}-py%{python3_version}.egg-info
c9aab32
224e11f
%if %{with mpich}
c9aab32
%files mpich
c9aab32
%license LICENSE
a8cb2ee
%doc README-Fedora.md SECURITY.md ACKNOWLEDGMENTS.md README.md CHANGES CONTRIBUTING.md
b6af78e
%{_libdir}/mpich/bin/%{name}_mpich
a8cb2ee
%{_libdir}/mpich/bin/%{name}-server_mpich
a8cb2ee
%{_libdir}/mpich/bin/%{name}-server-mpi_mpich
b6af78e
%{_libdir}/mpich/bin/%{name}_vars_mpich.sh
b6af78e
%{_libdir}/mpich/bin/%{name}-config_mpich
b6af78e
%{_libdir}/mpich/bin/sli_mpich
bded264
%{_libdir}/mpich/lib/*.so.3*
c9aab32
c9aab32
%files mpich-common
bded264
%license LICENSE
c9aab32
%{_libdir}/mpich/share/%{name}
c9aab32
5ba34ea
%files mpich-devel
99131e2
%{_includedir}/mpich-%{_arch}/%{name}
bded264
%{_libdir}/mpich/lib/*.so
cb7e44a
c9aab32
%files -n python3-%{name}-mpich
c9aab32
%license LICENSE
c9aab32
%{python3_sitearch}/mpich/%{name}
a8cb2ee
%{python3_sitearch}/mpich/nest_simulator-%{version}-py%{python3_version}.egg-info
c9aab32
%endif
c9aab32
224e11f
%if %{with openmpi}
c9aab32
%files openmpi
c9aab32
%license LICENSE
a8cb2ee
%doc README-Fedora.md SECURITY.md ACKNOWLEDGMENTS.md README.md CHANGES CONTRIBUTING.md
b6af78e
%{_libdir}/openmpi/bin/%{name}_openmpi
a8cb2ee
%{_libdir}/openmpi/bin/%{name}-server_openmpi
a8cb2ee
%{_libdir}/openmpi/bin/%{name}-server-mpi_openmpi
b6af78e
%{_libdir}/openmpi/bin/%{name}_vars_openmpi.sh
b6af78e
%{_libdir}/openmpi/bin/%{name}-config_openmpi
b6af78e
%{_libdir}/openmpi/bin/sli_openmpi
bded264
%{_libdir}/openmpi/lib/*.so.3*
c9aab32
c9aab32
%files openmpi-common
bded264
%license LICENSE
c9aab32
%{_libdir}/openmpi/share/%{name}
c9aab32
5ba34ea
%files openmpi-devel
99131e2
%{_includedir}/openmpi-%{_arch}/%{name}
bded264
%{_libdir}/openmpi/lib/*.so
cb7e44a
c9aab32
%files -n python3-%{name}-openmpi
c9aab32
%license LICENSE
c9aab32
%{python3_sitearch}/openmpi/%{name}
a8cb2ee
%{python3_sitearch}/openmpi/nest_simulator-%{version}-py%{python3_version}.egg-info
c9aab32
%endif
c9aab32
c9aab32
%changelog
9f26967
%autochangelog