%global srcname PyLEMS
%global libname pylems
%global commit a96812a2a979a0bb4c503c6459d14e7d3602ea7c
%global shortcommit %(c=%{commit}; echo ${c:0:7})
# https://fedoraproject.org/wiki/Packaging:DistTag?rd=Packaging/DistTag#Conditionals
%if 0%{?fedora} < 30
%global with_py2 1
%else
%global with_py2 0
%endif
# Most tests try to download files from other github repos, so we cannot use them
%global run_tests 0
%global _description \
A LEMS (http://lems.github.io/LEMS) simulator written in Python which can be \
used to run NeuroML2 (http://neuroml.org/neuroml2.php) models.
Name: python-%{srcname}
Version: 0.4.9.1
Release: 1%{?dist}
Summary: LEMS interpreter implemented in Python
License: LGPLv3
# Use github source. Pypi source does not include license and examples.
URL: https://github.com/LEMS/%{libname}/
Source0: https://github.com/LEMS/%{libname}/archive/%{commit}/%{libname}-%{shortcommit}.tar.gz
BuildArch: noarch
%description
%{_description}
%package -n python3-%{srcname}
Summary: %{summary}
BuildRequires: python3-devel
BuildRequires: %{py3_dist lxml}
Requires: %{py3_dist lxml}
Requires: %{py3_dist matplotlib}
Requires: %{py3_dist numpy}
%if %{run_tests}
BuildRequires: %{py3_dist nose}
%endif
%{?python_provide:%python_provide python3-%{srcname}}
%description -n python3-%{srcname}
%{_description}
%package doc
Summary: %{summary}
%description doc
%{_description}
%if %{with_py2}
%package -n python2-%{srcname}
Summary: %{summary}
BuildRequires: python2-devel
BuildRequires: %{py2_dist lxml}
Requires: %{py2_dist lxml}
Requires: %{py2_dist matplotlib}
Requires: %{py2_dist numpy}
%if %{run_tests}
BuildRequires: %{py2_dist nose}
%endif
%{?python_provide:%python_provide python2-%{srcname}}
%description -n python2-%{srcname}
%{_description}
%endif
%prep
%autosetup -n %{libname}-%{commit}
# remove shebang
sed -i '1d' lems/dlems/exportdlems.py
%build
%py3_build
%if %{with_py2}
%py2_build
%endif
%install
%py3_install
%if %{with_py2}
%py2_install
%endif
%check
%if %{run_tests}
# From test*sh scripts in the source and .travis.yml
nosetests-3
PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} examples/apitest.py
PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} examples/apitest2.py
PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} examples/loadtest.py
PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} lems/dlems/exportdlems.py
%if %{with_py2}
nosetests-2
PYTHONPATH=%{buildroot}%{python2_sitelib} %{__python2} examples/apitest.py
PYTHONPATH=%{buildroot}%{python2_sitelib} %{__python2} examples/apitest2.py
PYTHONPATH=%{buildroot}%{python2_sitelib} %{__python2} examples/loadtest.py
PYTHONPATH=%{buildroot}%{python2_sitelib} %{__python2} lems/dlems/exportdlems.py
%endif
%endif
%files -n python3-%{srcname}
%license LICENSE.lesser
%doc README.md
%{python3_sitelib}/%{srcname}-%{version}-py3.?.egg-info
%{python3_sitelib}/lems
%{_bindir}/%{libname}
%files doc
%license LICENSE.lesser
%doc README.md examples
%if %{with_py2}
%files -n python2-%{srcname}
%license LICENSE.lesser
%doc README.md
%{python2_sitelib}/%{srcname}-%{version}-py2.?.egg-info
%{python2_sitelib}/lems
%{_bindir}/%{libname}
%endif
%changelog
* Sat Oct 27 2018 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.4.9.1-1
- Initial build