Blob Blame History Raw
%bcond_without tests

# Do not build docs, bundle JS etc.
# Point to upstream docs instead
%bcond_with docs

%global desc %{expand: \
Brian2 is a simulator for spiking neural networks available on almost all
platforms. The motivation for this project is that a simulator should not only
save the time of processors, but also the time of scientists.

It is the successor of Brian1 and shares its approach of being highly flexible
and easily extensible. It is based on a code generation framework that allows
to execute simulations using other programming languages and/or on different

Please report issues to the github issue tracker
( or to the brian support mailing
list (

Documentation for Brian2 can be found at}

Name:           python-brian2
Version:        2.5.1
Release:        %autorelease
Summary:        A clock-driven simulator for spiking neural networks

License:        CECILL-2.0
Source0:        %pypi_source Brian2
Patch0:         0001-Brian2-2.2-remove-crosscompiling.patch

BuildRequires:  gcc-c++ gcc
BuildRequires:  gsl-devel


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

%if %{with docs}
BuildRequires:  %{py3_dist sphinx}

Suggests:       %{py3_dist ipython}
%py_provides python3-brian2

%description -n python3-brian2

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

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

%autosetup -n Brian2-%{version}

# Remove unnecessary files
find . -name ".gitignore" -print -delete
rm -rvf Brian2.egg-info
rm -f brian2/synapses/cythonspikequeue.cpp

# Correct shebang for examples
find examples -name "*.py" -print -exec sed -i 's|^#!/usr/bin/env python|#!/usr/bin/python3|' '{}' \;

%pyproject_buildrequires -r %{?with_tests:-x test}

%if %{with docs}
# Build documentation
sphinx-build-3 docs_sphinx html

%pyproject_save_files brian2

%pyproject_check_import -e brian2.hears -t

%if %{with tests}
# prevent direct import
pushd ../
PYTHONPATH=$RPM_BUILD_ROOT/%{python3_sitearch}/ %{python3} -c 'import brian2; brian2.test(test_openmp=True, test_GSL=True, test_codegen_independent=True, test_in_parallel=["codegen_independent", "numpy", "cpp_standalone"])'

# remove pytest_cache
rm -rf $RPM_BUILD_ROOT/%{python3_sitearch}/brian2/{tests,}/.pytest_cache/

%files -n python3-brian2 -f %{pyproject_files}
%doc README.rst

%files doc
%license LICENSE
%doc examples
%if %{with docs}
%doc html