921bcd
%bcond_without python3
921bcd
%global pypi_name chardet
921bcd
Name:           python-%{pypi_name}
921bcd
Version:        3.0.4
921bcd
Release:        9%{?dist}
921bcd
Summary:        Character encoding auto-detection in Python
921bcd
921bcd
Group:          Development/Languages
921bcd
License:        LGPLv2
921bcd
URL:            https://github.com/%{pypi_name}/%{pypi_name}
921bcd
Source0:        https://files.pythonhosted.org/packages/source/c/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
921bcd
921bcd
BuildArch:      noarch
921bcd
BuildRequires:  python2-devel, python2-setuptools
921bcd
921bcd
%if %{with python3}
921bcd
BuildRequires:  python3-devel, python3-setuptools
921bcd
%endif # with python3
921bcd
921bcd
%global _description\
921bcd
Character encoding auto-detection in Python. As\
921bcd
smart as your browser. Open source.
921bcd
921bcd
%description %_description
921bcd
921bcd
%package -n python2-%{pypi_name}
921bcd
Summary: %summary
921bcd
%{?python_provide:%python_provide python2-%{pypi_name}}
921bcd
921bcd
%description -n python2-%{pypi_name} %_description
921bcd
921bcd
%if %{with python3}
921bcd
%package -n python3-%{pypi_name}
921bcd
Summary:        Character encoding auto-detection in Python 3
921bcd
921bcd
%description -n python3-%{pypi_name}
921bcd
Character encoding auto-detection in Python. As 
921bcd
smart as your browser. Open source.
921bcd
921bcd
Python 3 version.
921bcd
%endif # with python3
921bcd
921bcd
%prep
921bcd
%setup -q -n %{pypi_name}-%{version}
921bcd
sed -ie '1d' %{pypi_name}/cli/chardetect.py
921bcd
921bcd
%if %{with python3}
921bcd
rm -rf %{py3dir}
921bcd
cp -a . %{py3dir}
921bcd
%endif # with python3
921bcd
921bcd
%build
921bcd
%{__python2} setup.py build
921bcd
921bcd
%if %{with python3}
921bcd
pushd %{py3dir}
921bcd
%{__python3} setup.py build
921bcd
popd
921bcd
%endif # with python3
921bcd
921bcd
921bcd
%install
921bcd
# Do Python 3 first not to overwrite the entrypoint
921bcd
%if %{with python3}
921bcd
pushd %{py3dir}
921bcd
%{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
921bcd
mv $RPM_BUILD_ROOT%{_bindir}/{,python3-}chardetect
921bcd
popd
921bcd
%endif # with python3
921bcd
921bcd
%{__python2} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
921bcd
mv $RPM_BUILD_ROOT%{_bindir}/chardetect{,-%{python2_version}}
921bcd
ln -s chardetect-%{python2_version} $RPM_BUILD_ROOT%{_bindir}/chardetect-2
921bcd
921bcd
%files -n python2-%{pypi_name}
921bcd
%{!?_licensedir:%global license %%doc}
921bcd
%license LICENSE
921bcd
%doc README.rst
921bcd
%{python2_sitelib}/*
921bcd
%{_bindir}/chardetect-2
921bcd
%{_bindir}/chardetect-%{python2_version}
921bcd
921bcd
%if %{with python3}
921bcd
%files -n python3-%{pypi_name}
921bcd
%{!?_licensedir:%global license %%doc}
921bcd
%license LICENSE
921bcd
%doc README.rst
921bcd
%{python3_sitelib}/*
921bcd
%{_bindir}/python3-chardetect
921bcd
%endif # with python3
921bcd
921bcd
921bcd
%changelog
921bcd
* Wed Aug 08 2018 Lumír Balhar <lbalhar@redhat.com> - 3.0.4-9
921bcd
- Remove unversioned binaries from python2 subpackage
921bcd
- Resolves: rhbz#1613343
921bcd
921bcd
* Tue Jul 31 2018 Lumír Balhar <lbalhar@redhat.com> - 3.0.4-8
921bcd
- Switch python3 conditions to bcond
921bcd
921bcd
* Mon Jul 16 2018 Lumír Balhar <lbalhar@redhat.com> - 3.0.4-7
921bcd
- First version for python27 module