Blob Blame Raw
# what it's called on pypi
%global srcname Automat
# what it's imported as
%global libname automat
# name of egg info directory
%global eggname %{srcname}
# package name fragment
%global pkgname %{srcname}

%global common_description %{expand:
Automat is a library for concise, idiomatic Python expression of finite-state
automata (particularly deterministic finite-state transducers).}

%bcond_without  tests
%bcond_without  python2

Name:           python-%{pkgname}
Version:        0.7.0
Release:        2%{?dist}
Summary:        Self-service finite-state machines for the programmer on the go

License:        MIT
URL:            https://github.com/glyph/automat
Source0:        %pypi_source
BuildArch:      noarch

%{?python_enable_dependency_generator}

%description %{common_description}


%if %{with python2}
%package -n     python2-%{pkgname}
Summary:        %{summary}
Provides:       python2-%{libname}
%{?python_provide:%python_provide python2-%{pkgname}}

BuildRequires:  python2-devel
BuildRequires:  python2dist(m2r)
BuildRequires:  python2dist(setuptools)
BuildRequires:  python2dist(setuptools-scm)
%if %{with tests}
BuildRequires:  python2dist(pytest)
BuildRequires:  python2dist(attrs) >= 16.1.0
BuildRequires:  python2dist(graphviz) > 0.5.1
BuildRequires:  python2dist(six)
BuildRequires:  python2dist(twisted) >= 16.1.1
%endif

%description -n python2-%{pkgname} %{common_description}
%endif


%package -n     python3-%{pkgname}
Summary:        %{summary}
Provides:       python3-%{libname}
%{?python_provide:%python_provide python3-%{pkgname}}

BuildRequires:  python3-devel
BuildRequires:  python3dist(m2r)
BuildRequires:  python3dist(setuptools)
BuildRequires:  python3dist(setuptools-scm)
%if %{with tests}
BuildRequires:  python3dist(pytest)
BuildRequires:  python3dist(attrs) >= 16.1.0
BuildRequires:  python3dist(graphviz) > 0.5.1
BuildRequires:  python3dist(six)
BuildRequires:  python3dist(twisted) >= 16.1.1
%endif

%description -n python3-%{pkgname} %{common_description}


%prep
%autosetup -n %{srcname}-%{version}
# Remove bundled egg-info
rm -rf %{eggname}.egg-info


%build
%if %{with python2}
%py2_build
%endif
%py3_build


%install
# Must do the default python version install last because
# the scripts in /usr/bin are overwritten with every setup.py install.
%if %{with python2}
%py2_install
rm -rf %{buildroot}%{_bindir}/*
%endif
%py3_install


%check
%if %{with tests}
%if %{with python2}
PYTHONPATH=%{buildroot}%{python2_sitelib} pytest-%{python2_version} --verbose automat/_test
%endif
PYTHONPATH=%{buildroot}%{python3_sitelib} pytest-%{python3_version} --verbose automat/_test
%endif


%if %{with python2}
%files -n python2-%{pkgname}
%license LICENSE
%doc README.md
%{python2_sitelib}/%{libname}
%{python2_sitelib}/%{eggname}-%{version}-py%{python2_version}.egg-info
%endif


%files -n python3-%{pkgname}
%license LICENSE
%doc README.md
%{_bindir}/automat-visualize
%{python3_sitelib}/%{libname}
%{python3_sitelib}/%{eggname}-%{version}-py%{python3_version}.egg-info


%changelog
* Sat Apr 06 2019 Carl George <carl@george.computer> - 0.7.0-2
- Add provides for lowercase name
- Run tests with pytest like upstream does

* Mon Mar 11 2019 Robert-André Mauchin <zebob.m@gmail.com> - 0.7.0-1
- Release 0.7.0 (#1687495)

* Fri Mar 08 2019 Jeroen van Meeuwen <vanmeeuwen+fedora@kolabsys.com> - 0.6.0-5
 - Add bcond_without tests

* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 0.6.0-2
- Rebuilt for Python 3.7

* Fri Apr 13 2018 Robert-André Mauchin <zebob.m@gmail.com> - 0.6.0-1
- Initial package.