File nest.spec of Package nest

#
# spec file for package nest
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%bcond_with mpi

Name:           nest
Version:        3.3
Release:        0
Summary:        Neuron simulator
License:        GPL-2.0-or-later
Group:          Productivity/Scientific/Other
URL:            https://www.nest-initiative.org/
Source0:        https://github.com/nest/nest-simulator/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
# PATCH-FIX-UPSTREAM -- https://github.com/nest/nest-simulator/issues/2438
Patch0:         0001-Use-correct-relative-paths-for-RUNPATH.patch
Patch1:         0002-Set-only-relevant-RUNPATHs-for-executable-and-librar.patch
# PATCH-FIX-OPENSUSE -- https://github.com/nest/nest-simulator/issues/2300
Patch2:         Fix-Python-DESTDIR.patch
BuildRequires:  cmake >= 3.12
BuildRequires:  doxygen
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  libboost_headers-devel
BuildRequires:  libneurosim-devel
BuildRequires:  pkgconfig
BuildRequires:  python3-Cython >= 0.19.2
BuildRequires:  python3-IPython
BuildRequires:  python3-matplotlib
BuildRequires:  python3-nose2
BuildRequires:  python3-numpy-devel
BuildRequires:  python3-scipy
BuildRequires:  readline-devel
BuildRequires:  pkgconfig(gsl)
BuildRequires:  pkgconfig(python3) >= 3.8
%if %{with mpi}
BuildRequires:  libmusic-devel
BuildRequires:  openmpi-devel
%endif

%description
NEST is a simulator for spiking neural network models that focus on
the dynamics, size and structure of neural systems rather than on the
exact morphology of individual neurons.

NEST is ideal for networks of spiking neurons of any size,
for example:

  - Models of information processing e.g. in the visual or auditory
    cortex of mammals,
  - Models of network activity dynamics, e.g. laminar cortical
    networks or balanced random networks,
  - Models of learning and plasticity.

%package devel
Summary:        Development files for %{name}
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}

%description devel
Development libraries and headers needed
to build packages using %{name}

%package doc
Summary:        Documentation for %{name}
Group:          Productivity/Scientific/Other
Recommends:     %{name} = %{version}
BuildArch:      noarch

%description doc
Documentation and examples for %{name}.

%package -n python3-nest
Summary:        Python 3 bindings for the %{name} neuron simulator
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}
Requires:       python3-IPython
Requires:       python3-matplotlib
Requires:       python3-numpy
Requires:       python3-scipy

%description -n python3-nest
NEST is a simulator for spiking neural network models that focus on
the dynamics, size and structure of neural systems rather than on the
exact morphology of individual neurons.

This package provides the Python 3.x bindings for %{name}

%prep
%autosetup -p1 -n nest-simulator-%{version}

%build
%global optflags %{optflags} -Wno-error=return-type
%cmake \
  %{?with_mpi:-Dwith-mpi:BOOL=ON -Dwith-music:BOOL=ON } \
  %{nil}
%cmake_build

%install
%cmake_install

# patch env interpreter
find -type f -name '*.py' -exec sed -i '1s|^#!.*python3|#!%{_bindir}/python3|' {} \;

%check
%if 0
# Current makefiles require the tests to be installed, and without any
# prefix (DESTDIR). See e.g. https://github.com/nest/nest-simulator/issues/2191
%ctest
%endif

%files
%doc CHANGES README.md
%license LICENSE
%{_bindir}/*
%dir %{_libdir}/%{name}
# libraries are unversioned
%{_libdir}/%{name}/*.so
%{_datadir}/%{name}/
%exclude %{_datadir}/%{name}/testsuite/
%exclude %{_docdir}/%{name}/*/
%exclude %{_docdir}/%{name}/*.sh

%files devel
%{_includedir}/%{name}

%files -n python3-nest
%{python3_sitearch}/nest

%files doc
%{_docdir}/%{name}/
%exclude %{_docdir}/%{name}/CHANGES
%exclude %{_docdir}/%{name}/README.md
%exclude %{_docdir}/%{name}/LICENSE

%changelog
openSUSE Build Service is sponsored by