8b32812
%bcond_with mpich
8b32812
%bcond_with openmpi
82e6277
82e6277
# Issue filed about warnings while compiling NEURON mod files:
82e6277
# https://github.com/NeuralEnsemble/PyNN/issues/707
82e6277
82e6277
82e6277
# Exclude privately used libnrnmech from provides
82e6277
%global __provides_exclude ^libnrnmech\\.so.*$
8b32812
%global __requires_exclude ^libnrnmech\\.so.*$
82e6277
82e6277
%global _description %{expand:
82e6277
PyNN (pronounced 'pine') is a simulator-independent language for building
82e6277
neuronal network models.
82e6277
82e6277
In other words, you can write the code for a model once, using the PyNN API and
82e6277
the Python programming language, and then run it without modification on any
82e6277
simulator that PyNN supports (currently NEURON, NEST and Brian) and on a number
82e6277
of neuromorphic hardware systems.
82e6277
82e6277
The PyNN API aims to support modelling at a high-level of abstraction
82e6277
(populations of neurons, layers, columns and the connections between them)
82e6277
while still allowing access to the details of individual neurons and synapses
82e6277
when required. PyNN provides a library of standard neuron, synapse and synaptic
82e6277
plasticity models, which have been verified to work the same on the different
82e6277
supported simulators. PyNN also provides a set of commonly-used connectivity
82e6277
algorithms (e.g. all-to-all, random, distance-dependent, small-world) but makes
82e6277
it easy to provide your own connectivity in a simulator-independent way.
82e6277
82e6277
Even if you don’t wish to run simulations on multiple simulators, you may
82e6277
benefit from writing your simulation code using PyNN’s powerful, high-level
82e6277
interface. In this case, you can use any neuron or synapse model supported by
82e6277
your simulator, and are not restricted to the standard models.
82e6277
82e6277
Documentation: http://neuralensemble.org/docs/PyNN/
82e6277
Mailing list: https://groups.google.com/forum/?fromgroups#!forum/neuralensemble
82e6277
82e6277
This package supports the NEURON, NEST, and Brian simulators.}
82e6277
7e7114a
%global forgeurl https://github.com/NeuralEnsemble/PyNN
7e7114a
8d8d3bf
Name:           python-pynn
Packit aa29d49
Version:        0.12.3
7e7114a
7e7114a
%global tag %{version}
7e7114a
%forgemeta
7e7114a
3c01aa2
Release:        %autorelease
82e6277
Summary:        A package for simulator-independent specification of neuronal network models
82e6277
7e7114a
521d65f
# SPDX
521d65f
License:        CECILL-2.0
8d8d3bf
URL:            http://neuralensemble.org/PyNN/
e447f23
Source:         %forgesource
67ea9d5
67ea9d5
# Random123 does not build on these, so neither can NEURON, so nothing that
67ea9d5
# depends on NEURON supports them either
67ea9d5
# https://github.com/neuronsimulator/nrn/issues/114
d5a1df0
#
cd64a2b
# python-pyedflib does not support s390x, so the complete dep tree needs to also exclude it
cd64a2b
# https://src.fedoraproject.org/rpms/python-pyedflib/blob/rawhide/f/python-pyedflib.spec
d5a1df0
#
d5a1df0
# python-pynn: Build hangs on i686
d5a1df0
# https://bugzilla.redhat.com/show_bug.cgi?id=2155635
d5a1df0
# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
d5a1df0
ExcludeArch:    mips64r2 mips32r2 s390x %{ix86}
67ea9d5
5e3dbe3
# For extensions
5e3dbe3
BuildRequires:  boost-devel
82e6277
BuildRequires:  cmake
82e6277
BuildRequires:  gcc-c++
82e6277
BuildRequires:  gsl-devel
82e6277
BuildRequires:  ncurses-devel
82e6277
BuildRequires:  libtool-ltdl-devel
82e6277
BuildRequires:  readline-devel
82e6277
82e6277
BuildRequires:  python3-brian2
82e6277
BuildRequires:  python3-cheetah
82e6277
BuildRequires:  %{py3_dist h5py}
82e6277
BuildRequires:  %{py3_dist lazyarray}
82e6277
BuildRequires:  %{py3_dist matplotlib}
e447f23
BuildRequires:  %{py3_dist morphio}
82e6277
BuildRequires:  %{py3_dist neo}
82e6277
BuildRequires:  %{py3_dist numpy}
27be70c
BuildRequires:  %{py3_dist libneuroml}
27be70c
BuildRequires:  python3-nest >= 3.7
27be70c
BuildRequires:  nest-devel >= 3.7
27be70c
BuildRequires:  nest >= 3.7
27be70c
BuildRequires:  libneurosim-devel
82e6277
BuildRequires:  python3-neuron
27be70c
BuildRequires:  neuron-devel
82e6277
BuildRequires:  %{py3_dist quantities}
82e6277
8b32812
BuildRequires:  %{py3_dist pytest}
8b32812
82e6277
%if %{with mpich}
82e6277
BuildRequires:  python3-mpi4py-mpich
27be70c
BuildRequires:  python3-nest-mpich >= 3.7
27be70c
BuildRequires:  nest-mpich >= 3.7
82e6277
BuildRequires:  python3-neuron-mpich
82e6277
BuildRequires:  rpm-mpi-hooks
82e6277
BuildRequires:  mpich
82e6277
BuildRequires:  mpich-devel
82e6277
%endif
82e6277
82e6277
%if %{with openmpi}
82e6277
BuildRequires:  python3-mpi4py-openmpi
27be70c
BuildRequires:  python3-nest-openmpi >= 3.7
27be70c
BuildRequires:  nest-openmpi >= 3.7
82e6277
BuildRequires:  python3-neuron-openmpi
82e6277
BuildRequires:  rpm-mpi-hooks
82e6277
BuildRequires:  openmpi
82e6277
BuildRequires:  openmpi-devel
82e6277
%endif
5e3dbe3
27be70c
Obsoletes:      python3-pynn-devel < 0:0.12.3-1
82e6277
82e6277
%{?python_enable_dependency_generator}
82e6277
82e6277
%description %_description
82e6277
8d8d3bf
%package -n python3-pynn
82e6277
Summary:        %{summary}
82e6277
BuildRequires:  python3-devel
386e088
BuildRequires:  python3-setuptools
82e6277
8d8d3bf
%description -n python3-pynn %_description
82e6277
82e6277
%package doc
82e6277
Summary:        %{summary}
82e6277
BuildArch:      noarch
82e6277
82e6277
%description doc
82e6277
Documentation for %{name}.
82e6277
82e6277
%prep
27be70c
%forgeautosetup
8d8d3bf
rm -rfv PyNN-%{version}/pyNN.egg-info
82e6277
8b32812
# we install NEST libraries in standard directories, and that's where NEST expects to find extensions also
8b32812
sed -i 's|\${NEST_LIBDIR}/nest|\${NEST_LIBDIR}|' pyNN/nest/extensions/CMakeLists.txt
8b32812
82e6277
%build
e447f23
# TODO: investigate using pyproject macros, or other new non setup.py tools
82e6277
%py3_build
82e6277
82e6277
pushd ./build/lib/pyNN/neuron/nmodl/ || exit 1
82e6277
    nrnivmodl .
82e6277
popd
82e6277
# The tests however, look for these here, so we also build them
82e6277
pushd pyNN/neuron/nmodl || exit 1
82e6277
    nrnivmodl .
82e6277
popd
82e6277
82e6277
# NEST extensions: we build and install them ourselves
225fec0
pushd ./build/lib/pyNN/nest/extensions/ || exit 1
225fec0
    %cmake -Dwith-nest=%{_bindir}/nest-config
82e6277
    %cmake_build
82e6277
popd
82e6277
8b32812
82e6277
%install
82e6277
%py3_install
82e6277
82e6277
# Includes compiled arch specific files but installs in /lib
82e6277
# Manually move to arch specific folder
67ea9d5
%if "%{python3_sitelib}" != "%{python3_sitearch}"
82e6277
mkdir -p 0644 $RPM_BUILD_ROOT/%{python3_sitearch}/
82e6277
mv $RPM_BUILD_ROOT/%{python3_sitelib}/pyNN $RPM_BUILD_ROOT/%{python3_sitearch}/
8d8d3bf
mv $RPM_BUILD_ROOT/%{python3_sitelib}/PyNN-%{version}-py%{python3_version}.egg-info $RPM_BUILD_ROOT/%{python3_sitearch}/
67ea9d5
%endif
82e6277
8b32812
# NEST extensions
8b32812
pushd ./build/lib/pyNN/nest/extensions/ || exit 1
8b32812
    %cmake_install
8b32812
popd
8b32812
8b32812
# remove temporary build files
8b32812
rm -rf $RPM_BUILD_ROOT%{python3_sitearch}/pyNN/nest/extensions/redhat-linux-build/
8b32812
rm -rf $RPM_BUILD_ROOT%{python3_sitearch}/pyNN/nest/_build
82e6277
82e6277
%check
8b32812
# skip pyNN.nest because it looks for nest extensions outside the buildroot
8b32812
%py3_check_import pyNN pyNN.neuron pyNN.brian2
5e3dbe3
9b78fbd
%pytest test/unittests -k "not test_partitioning and not test_get"
5e3dbe3
82e6277
%if %{with mpich}
82e6277
%{_mpich_load}
5e3dbe3
export PYTHONPATH=$PYTHONPATH:$RPM_BUILD_ROOT/%{python3_sitearch}:$RPM_BUILD_ROOT/%{python3_sitelib}:$RPM_BUILD_ROOT/$MPI_PYTHON3_SITEARCH:$MPI_PYTHON3_SITEARCH
5e3dbe3
%py3_check_import pyNN pyNN.nest pyNN.neuron pyNN.brian2
5e3dbe3
8b32812
%pytest test/unittests
8b32812
5e3dbe3
unset PYTHONPATH
521d65f
%{_mpich_unload}
5e3dbe3
%endif
82e6277
82e6277
%if %{with openmpi}
82e6277
%{_openmpi_load}
5e3dbe3
export PYTHONPATH=$PYTHONPATH:$RPM_BUILD_ROOT/%{python3_sitearch}:$RPM_BUILD_ROOT/%{python3_sitelib}:$RPM_BUILD_ROOT/$MPI_PYTHON3_SITEARCH:$MPI_PYTHON3_SITEARCH
5e3dbe3
%py3_check_import pyNN pyNN.nest pyNN.neuron pyNN.brian2
5e3dbe3
8b32812
%pytest test/unittests
8b32812
5e3dbe3
unset PYTHONPATH
521d65f
%{_openmpi_unload}
82e6277
%endif
82e6277
82e6277
# These files are NEURON files that are required by PyNN to run bits using the NEURON backend
82e6277
# The libnrnmech.so file, along with the .libs/libnrnmech.so symlink are both required
82e6277
# So is the "special" script that loads these libraries
82e6277
# We can remove some temporary compilation files, though:
27be70c
find $RPM_BUILD_ROOT/%{python3_sitearch}/pyNN/neuron/nmodl/*/ -name "*.c" -o -name "*.mod" -delete
82e6277
82e6277
8d8d3bf
%files -n python3-pynn
82e6277
%license LICENSE
82e6277
%doc README.rst AUTHORS changelog
8b32812
%{_libdir}/*pynn*so
8d8d3bf
%{python3_sitearch}/pyNN
8d8d3bf
%{python3_sitearch}/PyNN-%{version}-py%{python3_version}.egg-info
82e6277
82e6277
%files doc
82e6277
%license LICENSE
82e6277
%doc examples
82e6277
82e6277
82e6277
%changelog
3c01aa2
%autochangelog