Remove Python 2 subpackage and make spec fedora-specific

This commit is contained in:
Lumir Balhar 2019-09-23 10:26:44 +02:00
parent 91c8794814
commit 1901358560

View File

@ -1,9 +1,7 @@
%global pypi_name packaging %global pypi_name packaging
%if 0%{?fedora} || 0%{?rhel} >= 8 # Specify --without wheel to prevent building the wheel
%global build_wheel 1 %bcond_without wheel
%global with_python3 1
%endif
# Specify --without docs to prevent the dependency loop on python-sphinx # Specify --without docs to prevent the dependency loop on python-sphinx
%bcond_without docs %bcond_without docs
@ -15,7 +13,7 @@
Name: python-%{pypi_name} Name: python-%{pypi_name}
Version: 19.0 Version: 19.0
Release: 5%{?dist} Release: 6%{?dist}
Summary: Core utilities for Python packages Summary: Core utilities for Python packages
License: BSD or ASL 2.0 License: BSD or ASL 2.0
@ -23,84 +21,37 @@ URL: https://github.com/pypa/packaging
Source0: https://files.pythonhosted.org/packages/source/p/%{pypi_name}/%{pypi_name}-%{version}.tar.gz Source0: https://files.pythonhosted.org/packages/source/p/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
BuildArch: noarch BuildArch: noarch
# Dependencies with different names in Fedora and Epel7 BuildRequires: python3-setuptools
%if 0%{?fedora} || 0%{?rhel} >= 8 BuildRequires: python3-devel
BuildRequires: python2-setuptools BuildRequires: python3-pyparsing
BuildRequires: python2-devel BuildRequires: python3-six
BuildRequires: python2-pyparsing
%if %{with tests} %if %{with tests}
BuildRequires: python2-pytest BuildRequires: python3-pytest
BuildRequires: python2-pretend BuildRequires: python3-pretend
%endif
%else
BuildRequires: python-setuptools
BuildRequires: python-devel
BuildRequires: pyparsing
%if %{with tests}
BuildRequires: pytest
BuildRequires: python2-pretend
%endif %endif
%if %{with docs} %if %{with docs}
BuildRequires: python-sphinx BuildRequires: python3-sphinx
%endif
%endif %endif
BuildRequires: python2-six %if %{with wheel}
BuildRequires: python3-pip
# Build Python 3 subpackage only for Fedora BuildRequires: python3-wheel
%if 0%{?with_python3}
BuildRequires: python%{python3_pkgversion}-setuptools
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-pyparsing
BuildRequires: python%{python3_pkgversion}-six
%if %{with tests}
BuildRequires: python%{python3_pkgversion}-pytest
BuildRequires: python%{python3_pkgversion}-pretend
%endif
%if %{with docs}
BuildRequires: python%{python3_pkgversion}-sphinx
%endif
%endif
%if 0%{?build_wheel}
%if 0%{?with_python3}
BuildRequires: python%{python3_pkgversion}-pip
BuildRequires: python%{python3_pkgversion}-wheel
%endif
%endif %endif
%description %description
python-packaging provides core utilities for Python packages like utilities for python-packaging provides core utilities for Python packages like utilities for
dealing with versions, specifiers, markers etc. dealing with versions, specifiers, markers etc.
%package -n python2-%{pypi_name} %package -n python3-%{pypi_name}
Summary: %{summary} Summary: %{summary}
%{?python_provide:%python_provide python2-%{pypi_name}} %{?python_provide:%python_provide python3-%{pypi_name}}
%if 0%{?fedora} || 0%{?rhel} >= 8 Requires: python3-pyparsing
Requires: python2-pyparsing Requires: python3-six
%else
Requires: pyparsing
%endif
Requires: python2-six %description -n python3-%{pypi_name}
%description -n python2-%{pypi_name}
python2-packaging provides core utilities for Python packages like utilities for
dealing with versions, specifiers, markers etc.
%if 0%{?with_python3}
%package -n python%{python3_pkgversion}-%{pypi_name}
Summary: %{summary}
%{?python_provide:%python_provide python%{python3_pkgversion}-%{pypi_name}}
Requires: python%{python3_pkgversion}-pyparsing
Requires: python%{python3_pkgversion}-six
%description -n python%{python3_pkgversion}-%{pypi_name}
python3-packaging provides core utilities for Python packages like utilities for python3-packaging provides core utilities for Python packages like utilities for
dealing with versions, specifiers, markers etc. dealing with versions, specifiers, markers etc.
%endif
%if %{with docs} %if %{with docs}
%package -n python-%{pypi_name}-doc %package -n python-%{pypi_name}-doc
@ -116,24 +67,15 @@ Documentation for python-packaging
rm -rf %{pypi_name}.egg-info rm -rf %{pypi_name}.egg-info
%build %build
%py2_build %if %{with wheel}
%if 0%{?with_python3}
%if 0%{?build_wheel}
%py3_build_wheel %py3_build_wheel
%else %else
%py3_build %py3_build
%endif %endif
%endif
%if %{with docs} %if %{with docs}
# generate html docs # generate html docs
%if 0%{?with_python3}
sphinx-build-3 docs html sphinx-build-3 docs html
%else
sphinx-build docs html
%endif
# remove the sphinx-build leftovers # remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo} rm -rf html/.{doctrees,buildinfo}
# Do not bundle fonts # Do not bundle fonts
@ -141,40 +83,22 @@ rm -rf html/_static/fonts/
%endif %endif
%install %install
%py2_install %if %{with wheel}
%if 0%{?with_python3}
%if 0%{?build_wheel}
%py3_install_wheel %{python_wheelname} %py3_install_wheel %{python_wheelname}
%else %else
%py3_install %py3_install
%endif %endif
%endif
%if %{with tests} %if %{with tests}
%check %check
%if 0%{?fedora} || 0%{?rhel} >= 8
%{__python2} -m pytest tests/
%{__python3} -m pytest tests/ %{__python3} -m pytest tests/
%else
# Disable non-working tests in Epel7
%{__python2} -m pytest --ignore=tests/test_requirements.py tests/
%endif
%endif %endif
%files -n python2-%{pypi_name} %files -n python3-%{pypi_name}
%license LICENSE LICENSE.APACHE LICENSE.BSD
%doc README.rst CHANGELOG.rst CONTRIBUTING.rst
%{python2_sitelib}/%{pypi_name}/
%{python2_sitelib}/%{pypi_name}-*-info/
%if 0%{?with_python3}
%files -n python%{python3_pkgversion}-%{pypi_name}
%license LICENSE LICENSE.APACHE LICENSE.BSD %license LICENSE LICENSE.APACHE LICENSE.BSD
%doc README.rst CHANGELOG.rst CONTRIBUTING.rst %doc README.rst CHANGELOG.rst CONTRIBUTING.rst
%{python3_sitelib}/%{pypi_name}/ %{python3_sitelib}/%{pypi_name}/
%{python3_sitelib}/%{pypi_name}-*-info/ %{python3_sitelib}/%{pypi_name}-*-info/
%endif
%if %{with docs} %if %{with docs}
%files -n python-%{pypi_name}-doc %files -n python-%{pypi_name}-doc
@ -183,6 +107,10 @@ rm -rf html/_static/fonts/
%endif %endif
%changelog %changelog
* Mon Sep 23 2019 Lumír Balhar <lbalhar@redhat.com> - 19.0-6
- Remove Python 2 subpackage
- Make spec fedora-specific
* Mon Sep 02 2019 Miro Hrončok <mhroncok@redhat.com> - 19.0-5 * Mon Sep 02 2019 Miro Hrončok <mhroncok@redhat.com> - 19.0-5
- Reduce Python 2 build time dependencies - Reduce Python 2 build time dependencies