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