Modernize spec

- only ship one version of the executable
- run tests
- drop python3 conditional
- use mdoern macros
- don't do py3dir
- remove Group definition
This commit is contained in:
Miro Hrončok 2018-08-17 14:16:55 +02:00
parent 481b4eaf24
commit 631a7704b8

View File

@ -1,21 +1,21 @@
%global with_python3 1
%global pypi_name chardet
Name: python-%{pypi_name}
Version: 3.0.4
Release: 7%{?dist}
Release: 8%{?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
Source0: %pypi_source
BuildArch: noarch
BuildRequires: python2-devel, python2-setuptools
BuildRequires: python2-devel
BuildRequires: python2-setuptools
BuildRequires: python2-pytest
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pytest
%if 0%{?with_python3}
BuildRequires: python3-devel, python3-setuptools
%endif # with_python3
%global _description\
Character encoding auto-detection in Python. As\
@ -29,65 +29,51 @@ Summary: %summary
%description -n python2-%{pypi_name} %_description
%if 0%{?with_python3}
%package -n python3-%{pypi_name}
Summary: Character encoding auto-detection in Python 3
%{?python_provide:%python_provide python3-%{pypi_name}}
%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 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
%endif # with_python3
%build
%{__python2} setup.py build
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py build
popd
%endif # with_python3
%py2_build
%py3_build
%install
# Do Python 3 first not to overwrite the entrypoint
%if 0%{?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
%py2_install
rm %{buildroot}%{_bindir}/*
%py3_install
%{__python2} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
%check
%{__python2} -m pytest -v
%{__python3} -m pytest -v
%files -n python2-%{pypi_name}
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc README.rst
%{python2_sitelib}/*
%{_bindir}/chardetect
%{python2_sitelib}/%{pypi_name}/
%{python2_sitelib}/%{pypi_name}-%{version}-py%{python2_version}.egg-info/
%if 0%{?with_python3}
%files -n python3-%{pypi_name}
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc README.rst
%{python3_sitelib}/*
%{_bindir}/python3-chardetect
%endif # with_python3
%{python3_sitelib}/%{pypi_name}/
%{python3_sitelib}/%{pypi_name}-%{version}-py%{python3_version}.egg-info/
%{_bindir}/chardetect
%changelog
* Fri Aug 17 2018 Miro Hrončok <mhroncok@redhat.com> - 3.0.4-8
- Only have one /usr/bin/chardetect
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.4-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild