-%define pname pyenchant
-Summary: Spellchecking library for Python
-Summary(pl.UTF-8): Biblioteka Pythona sprawdzająca pisownię
-Name: python-%{pname}
-Version: 1.5.3
-Release: 3
+#
+# Conditional build:
+%bcond_with tests # unit tests (require en_US dictionary)
+%bcond_without python2 # CPython 2.x module
+%bcond_without python3 # CPython 3.x module
+
+Summary: Spellchecking library for Python 2
+Summary(pl.UTF-8): Biblioteka Pythona 2 sprawdzająca pisownię
+Name: python-pyenchant
+Version: 2.0.0
+Release: 1
License: LGPL v2.1+
-Group: Libraries
-Source0: http://downloads.sourceforge.net/pyenchant/%{pname}-%{version}.tar.gz
-# Source0-md5: d327fb9c8620ecc261a424083dc9aa95
-Patch0: %{name}-ez_setup.patch
-URL: http://pyenchant.sourceforge.net/
-BuildRequires: rpmbuild(macros) >= 1.710
-BuildRequires: enchant-devel >= 1.3.0
-BuildRequires: python-devel
-BuildRequires: python-setuptools >= 0.6-0.c3
+Group: Libraries/Python
+#Source0Download: https://pypi.org/simple/pyenchant/
+Source0: https://files.pythonhosted.org/packages/source/p/pyenchant/pyenchant-%{version}.tar.gz
+# Source0-md5: c224ea53e119b04116d5301e5027051c
+URL: https://pypi.org/project/pyenchant/
+%if %{with python2}
+BuildRequires: python-devel >= 1:2.5
+BuildRequires: python-setuptools >= 1:7
+%endif
+%if %{with python3}
+BuildRequires: python3-2to3 >= 1:3.2
+BuildRequires: python3-devel >= 1:3.2
+BuildRequires: python3-setuptools >= 1:7
+%endif
BuildRequires: rpm-pythonprov
-%pyrequires_eq python-libs
-Requires: enchant >= 1.3.0
+BuildRequires: rpmbuild(macros) >= 1.714
+Requires: enchant >= 1.6.0
+Requires: python-libs >= 1:2.5
+BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
udostępniających świetną bibliotekę sprawdzania pisowni Enchant jako
moduł Pythona.
+%package -n python3-pyenchant
+Summary: Spellchecking library for Python 3
+Summary(pl.UTF-8): Biblioteka Pythona 3 sprawdzająca pisownię
+Group: Libraries/Python
+Requires: enchant >= 1.6.0
+Requires: python3-libs >= 1:3.2
+
+%description -n python3-pyenchant
+PyEnchant is a set of language bindings and some wrapper classes to
+make the excellent Enchant spellchecker available as a Python module.
+
+%description -n python3-pyenchant -l pl.UTF-8
+PyEnchant to zbiór dowiązań języka i klas obudowujących
+udostępniających świetną bibliotekę sprawdzania pisowni Enchant jako
+moduł Pythona.
+
%prep
-%setup -q -n %{pname}-%{version}
-%patch0 -p1
+%setup -q -n pyenchant-%{version}
%build
-%py_build
+%if %{with python2}
+%py_build %{?with_tests:test}
+%endif
+
+%if %{with python3}
+%py3_build %{?with_tests:test}
+%endif
%install
rm -rf $RPM_BUILD_ROOT
-%py_install \
- --root $RPM_BUILD_ROOT \
- --single-version-externally-managed
+%if %{with python2}
+%py_install
%py_postclean
+%{__rm} $RPM_BUILD_ROOT%{py_sitescriptdir}/enchant/tests.py*
+%endif
+
+%if %{with python3}
+%py3_install
+
+%{__rm} $RPM_BUILD_ROOT%{py3_sitescriptdir}/enchant/tests.py
+%{__rm} $RPM_BUILD_ROOT%{py3_sitescriptdir}/enchant/__pycache__/tests.*.py*
+%endif
%clean
rm -rf $RPM_BUILD_ROOT
+%if %{with python2}
%files
%defattr(644,root,root,755)
%doc README.txt TODO.txt
-%dir %{py_sitescriptdir}/enchant
-%{py_sitescriptdir}/enchant/*.py[co]
-%dir %{py_sitescriptdir}/enchant/checker
-%{py_sitescriptdir}/enchant/checker/*.py[co]
-%dir %{py_sitescriptdir}/enchant/tokenize
-%{py_sitescriptdir}/enchant/tokenize/*.py[co]
+%{py_sitescriptdir}/enchant
%{py_sitescriptdir}/pyenchant-%{version}-py*.egg-info
+%endif
+
+%if %{with python3}
+%files -n python3-pyenchant
+%defattr(644,root,root,755)
+%doc README.txt TODO.txt
+%{py3_sitescriptdir}/enchant
+%{py3_sitescriptdir}/pyenchant-%{version}-py*.egg-info
+%endif