Blob Blame History Raw
%bcond_with mpich
%bcond_with openmpi

# Issue filed about warnings while compiling NEURON mod files:

# Exclude privately used libnrnmech from provides
%global __provides_exclude ^libnrnmech\\.so.*$
%global __requires_exclude ^libnrnmech\\.so.*$

%global _description %{expand:
PyNN (pronounced 'pine') is a simulator-independent language for building
neuronal network models.

In other words, you can write the code for a model once, using the PyNN API and
the Python programming language, and then run it without modification on any
simulator that PyNN supports (currently NEURON, NEST and Brian) and on a number
of neuromorphic hardware systems.

The PyNN API aims to support modelling at a high-level of abstraction
(populations of neurons, layers, columns and the connections between them)
while still allowing access to the details of individual neurons and synapses
when required. PyNN provides a library of standard neuron, synapse and synaptic
plasticity models, which have been verified to work the same on the different
supported simulators. PyNN also provides a set of commonly-used connectivity
algorithms (e.g. all-to-all, random, distance-dependent, small-world) but makes
it easy to provide your own connectivity in a simulator-independent way.

Even if you don’t wish to run simulations on multiple simulators, you may
benefit from writing your simulation code using PyNN’s powerful, high-level
interface. In this case, you can use any neuron or synapse model supported by
your simulator, and are not restricted to the standard models.

Mailing list:!forum/neuralensemble

This package supports the NEURON, NEST, and Brian simulators.}

%global forgeurl

Name:           python-pynn
Version:        0.12.2

%global tag %{version}

Release:        %autorelease
Summary:        A package for simulator-independent specification of neuronal network models

License:        CECILL-2.0
Source:         %forgesource

# Random123 does not build on these, so neither can NEURON, so nothing that
# depends on NEURON supports them either
# python-pyedflib does not support s390x, so the complete dep tree needs to also exclude it
# python-pynn: Build hangs on i686
ExcludeArch:    mips64r2 mips32r2 s390x %{ix86}

# For extensions
BuildRequires:  boost-devel
BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  git-core
BuildRequires:  gsl-devel
BuildRequires:  libneurosim-devel
BuildRequires:  ncurses-devel
BuildRequires:  nest-devel >= 3.4
BuildRequires:  neuron-devel
BuildRequires:  libtool-ltdl-devel
BuildRequires:  readline-devel

BuildRequires:  python3-brian2
BuildRequires:  python3-cheetah
BuildRequires:  %{py3_dist h5py}
BuildRequires:  %{py3_dist lazyarray}
BuildRequires:  %{py3_dist matplotlib}
BuildRequires:  %{py3_dist morphio}
BuildRequires:  %{py3_dist neo}
BuildRequires:  %{py3_dist numpy}
BuildRequires:  python3-nest >= 3.4
BuildRequires:  nest >= 3.4
BuildRequires:  python3-neuron
BuildRequires:  %{py3_dist quantities}

BuildRequires:  %{py3_dist pytest}

%if %{with mpich}
BuildRequires:  python3-mpi4py-mpich
BuildRequires:  python3-nest-mpich >= 3.4
BuildRequires:  nest-mpich >= 3.4
BuildRequires:  python3-neuron-mpich
BuildRequires:  rpm-mpi-hooks
BuildRequires:  mpich
BuildRequires:  mpich-devel

%if %{with openmpi}
BuildRequires:  python3-mpi4py-openmpi
BuildRequires:  python3-nest-openmpi >= 3.4
BuildRequires:  nest-openmpi >= 3.4
BuildRequires:  python3-neuron-openmpi
BuildRequires:  rpm-mpi-hooks
BuildRequires:  openmpi
BuildRequires:  openmpi-devel


%description %_description

%package devel
Summary:        %{summary}
Requires:       python3-pynn%{?_isa} = %{version}-%{release}

%description devel %_description

%package -n python3-pynn
Summary:        %{summary}
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools

%description -n python3-pynn %_description

%package doc
Summary:        %{summary}
BuildArch:      noarch

%description doc
Documentation for %{name}.

%forgeautosetup -S git
rm -rfv PyNN-%{version}/pyNN.egg-info

# we install NEST libraries in standard directories, and that's where NEST expects to find extensions also
sed -i 's|\${NEST_LIBDIR}/nest|\${NEST_LIBDIR}|' pyNN/nest/extensions/CMakeLists.txt

# TODO: investigate using pyproject macros, or other new non tools

pushd ./build/lib/pyNN/neuron/nmodl/ || exit 1
    nrnivmodl .
# The tests however, look for these here, so we also build them
pushd pyNN/neuron/nmodl || exit 1
    nrnivmodl .

# NEST extensions: we build and install them ourselves
pushd ./build/lib/pyNN/nest/extensions/ || exit 1
    %cmake -Dwith-nest=%{_bindir}/nest-config


# Includes compiled arch specific files but installs in /lib
# Manually move to arch specific folder
%if "%{python3_sitelib}" != "%{python3_sitearch}"
mkdir -p 0644 $RPM_BUILD_ROOT/%{python3_sitearch}/
mv $RPM_BUILD_ROOT/%{python3_sitelib}/pyNN $RPM_BUILD_ROOT/%{python3_sitearch}/
mv $RPM_BUILD_ROOT/%{python3_sitelib}/PyNN-%{version}-py%{python3_version}.egg-info $RPM_BUILD_ROOT/%{python3_sitearch}/

# NEST extensions
pushd ./build/lib/pyNN/nest/extensions/ || exit 1

# remove temporary build files
rm -rf $RPM_BUILD_ROOT%{python3_sitearch}/pyNN/nest/extensions/redhat-linux-build/
rm -rf $RPM_BUILD_ROOT%{python3_sitearch}/pyNN/nest/_build

# skip pyNN.nest because it looks for nest extensions outside the buildroot
%py3_check_import pyNN pyNN.neuron pyNN.brian2

%pytest test/unittests -k "not test_partitioning and not test_get"

%if %{with mpich}
%py3_check_import pyNN pyNN.nest pyNN.neuron pyNN.brian2

%pytest test/unittests


%if %{with openmpi}
%py3_check_import pyNN pyNN.nest pyNN.neuron pyNN.brian2

%pytest test/unittests


# These files are NEURON files that are required by PyNN to run bits using the NEURON backend
# The file, along with the .libs/ symlink are both required
# So is the "special" script that loads these libraries
# We can remove some temporary compilation files, though:
find $RPM_BUILD_ROOT/%{python3_sitearch}/pyNN/neuron/nmodl/*/ -name "*.c" -o -name "*.c" -o -name "*.mod" -delete

%files -n python3-pynn
%license LICENSE
%doc README.rst AUTHORS changelog

%files devel

%files doc
%license LICENSE
%doc examples