File python-brian.spec of Package python-brian

#
# spec file for package python-brian
#
# Copyright (c) 2016 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


Name:           python-brian
Version:        1.4.3
Release:        0
Summary:        A clock-driven simulator for spiking neural networks
License:        CECILL-1.0
Group:          Development/Languages/Python
Url:            http://www.briansimulator.org/
Source:         https://pypi.python.org/packages/source/b/brian/brian-%{version}.tar.gz
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  python-devel >= 2.5
BuildRequires:  python-matplotlib >= 0.90.1
BuildRequires:  python-numpy-devel >= 1.4.1
BuildRequires:  python-scipy >= 0.7.0
BuildRequires:  python-scipy-weave
BuildRequires:  python-sympy
Requires:       python-matplotlib >= 0.90.1
Requires:       python-numpy >= 1.4.1
Requires:       python-scipy >= 0.7.0
Requires:       python-sympy
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitearch: %global python_sitearch %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
%endif

%description
Brian 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.

Brian is easy to learn and use, highly flexible and easily extensible. The Brian package
itself and simulations using it are all written in the Python programming language,
which is an easy, concise and highly developed language with many advanced features and
development tools, excellent documentation and a large community of users providing
support and extension packages.

%package weave
Summary:        Optimizations for %{name} using scipy weave
Group:          Development/Languages/Python
Requires:       gcc-c++
Requires:       %{name} = %{version}
Requires:       python-scipy-weave

%description weave
Brian 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.

Brian is easy to learn and use, highly flexible and easily extensible. The Brian package
itself and simulations using it are all written in the Python programming language,
which is an easy, concise and highly developed language with many advanced features and
development tools, excellent documentation and a large community of users providing
support and extension packages.

This package allows Brian to optimize simulations using scipy weave.  This should
provide substantial performance improvements on most systems, but may
reduce performance in some cases.


%package cspikequeue
Summary:        Optimized spike queue for %{name}
Group:          Development/Languages/Python
Requires:       %{name} = %{version}

%description cspikequeue
Brian 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.

Brian is easy to learn and use, highly flexible and easily extensible. The Brian package
itself and simulations using it are all written in the Python programming language,
which is an easy, concise and highly developed language with many advanced features and
development tools, excellent documentation and a large community of users providing
support and extension packages.

This package provides the experimental c-optimized spike queue.  This should
provide substantial performance improvements on most systems, but may
reduce performance in some cases.

%prep
%setup -q -n brian-%{version}

%build
# fix wrong-file-end-of-line-encoding
sed -i 's/\r$//' README.txt
sed -i 's/\r$//' brian/utils/ccircular/setup.py
sed -i 's/\r$//' brian/utils/fastexp/setup.py

CFLAGS="%{optflags}" python setup.py build

%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}

# build optimized spikequeue
pushd %{buildroot}%{python_sitearch}/brian/experimental/cspikequeue/
python setup.py build_ext --inplace
rm -r build
popd

# setup weave optimizations
echo '#!/usr/bin/env python
"""use scipy weave optimization in the brian brain simulator"""
from brian.globalprefs import *
set_global_preferences(useweave=True, openmp=True)' > %{buildroot}%{python_sitearch}/brian_global_config.py

chmod a+x %{buildroot}/%{python_sitearch}/brian_global_config.py
chmod a+x %{buildroot}/%{python_sitearch}/brian/experimental/cspikequeue/setup.py 
chmod a+x %{buildroot}/%{python_sitearch}/brian/utils/ccircular/setup.py
chmod a+x %{buildroot}/%{python_sitearch}/brian/utils/fastexp/setup.py

# Remove duplicates
%fdupes %{buildroot}

# Fix python-bytecode-inconsistent-mtime
pushd %{buildroot}%{python_sitearch}
%py_compile .
popd

%files
%defattr(-,root,root,-)
%doc README.txt
%{python_sitearch}/brian/
%{python_sitearch}/brian_*.py*
%{python_sitearch}/brian-%{version}-py*.egg-info
%exclude %{python_sitearch}/brian/experimental/cspikequeue/*.so
%exclude %{python_sitearch}/brian_global_config.py*

%files weave
%defattr(-,root,root,-)
%{python_sitearch}/brian_global_config.py*

%files cspikequeue
%defattr(-,root,root,-)
%{python_sitearch}/brian/experimental/cspikequeue/*.so

%changelog
openSUSE Build Service is sponsored by