CentOS 8: python-glanceclient should use python3

Change python to python3
get spec files from upstream to support python3

Change-Id: I033eeea6077fce7ff8deb44739c179c86d0f15a3
Story: 2006729
Task: 38640
Signed-off-by: Yong Fu <fuyong@neusoft.com>
This commit is contained in:
Yong Fu 2020-06-12 14:53:19 +08:00 committed by Long Li
parent 2201c17252
commit 35e5af948d
1 changed files with 81 additions and 108 deletions

View File

@ -1,12 +1,20 @@
# Macros for py2/py3 compatibility
%if 0%{?fedora} || 0%{?rhel} > 7
%global pyver %{python3_pkgversion}
%else
%global pyver 2
%endif
%global pyver_bin python%{pyver}
%global pyver_sitelib %{expand:%{python%{pyver}_sitelib}}
%global pyver_install %{expand:%{py%{pyver}_install}}
%global pyver_build %{expand:%{py%{pyver}_build}}
%global pyver_build_wheel %{expand:%{py%{pyver}_build_wheel}}
# End of macros for py2/py3 compatibility
%{!?upstream_version: %global upstream_version %{version}%{?milestone}}
%global sname glanceclient
%global with_doc 0
%if 0%{?fedora}
%global with_python3 1
%endif
%global common_desc \
This is a client for the OpenStack Glance API. There's a Python API (the \
glanceclient module), and a command-line script (glance). Each implements \
@ -30,74 +38,55 @@ BuildRequires: openstack-macros
%description
%{common_desc}
%package -n python2-%{sname}
%package -n python%{pyver}-%{sname}
Summary: Python API and CLI for OpenStack Glance
%{?python_provide:%python_provide python2-glanceclient}
%{?python_provide:%python_provide python%{pyver}-glanceclient}
%if %{pyver} == 3
Obsoletes: python2-%{sname} < %{version}-%{release}
%endif
BuildRequires: python2-devel
BuildRequires: python2-pip
BuildRequires: python2-wheel
BuildRequires: python2-setuptools
BuildRequires: python2-pbr
BuildRequires: python%{pyver}-devel
BuildRequires: python%{pyver}-setuptools
BuildRequires: python%{pyver}-pbr
BuildRequires: python%{pyver}-wheel
Requires: python2-keystoneauth1 >= 3.6.2
Requires: python2-oslo-i18n >= 3.15.3
Requires: python2-oslo-utils >= 3.33.0
Requires: python2-pbr
Requires: python2-prettytable
Requires: python2-pyOpenSSL >= 17.1.0
Requires: python2-requests
Requires: python2-six >= 1.10.0
%if 0%{?fedora} || 0%{?rhel} > 7
Requires: python2-warlock
Requires: python2-wrapt
%else
Requires: python%{pyver}-keystoneauth1 >= 3.6.2
Requires: python%{pyver}-oslo-i18n >= 3.15.3
Requires: python%{pyver}-oslo-utils >= 3.33.0
Requires: python%{pyver}-pbr
Requires: python%{pyver}-prettytable
Requires: python%{pyver}-pyOpenSSL >= 17.1.0
Requires: python%{pyver}-requests
Requires: python%{pyver}-six >= 1.10.0
# Handle python2 exception
%if %{pyver} == 2
Requires: python-warlock
Requires: python-wrapt
%else
Requires: python%{pyver}-warlock
Requires: python%{pyver}-wrapt
%endif
%description -n python2-%{sname}
%description -n python%{pyver}-%{sname}
%{common_desc}
%if 0%{?with_python3}
%package -n python3-%{sname}
Summary: Python API and CLI for OpenStack Glance
%{?python_provide:%python_provide python3-glanceclient}
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pbr
Requires: python3-keystoneauth1 >= 3.6.2
Requires: python3-oslo-i18n >= 3.15.3
Requires: python3-oslo-utils >= 3.33.0
Requires: python3-pbr
Requires: python3-prettytable
Requires: python3-pyOpenSSL >= 17.1.0
Requires: python3-requests
Requires: python3-six >= 1.10.0
Requires: python3-warlock
Requires: python3-wrapt
%description -n python3-%{sname}
%{common_desc}
%endif
%if 0%{?with_doc}
%package doc
Summary: Documentation for OpenStack Glance API Client
BuildRequires: python2-sphinx
BuildRequires: python2-openstackdocstheme
BuildRequires: python2-keystoneauth1
BuildRequires: python2-oslo-utils
BuildRequires: python2-prettytable
BuildRequires: python2-pyOpenSSL >= 17.1.0
BuildRequires: python2-sphinxcontrib-apidoc
%if 0%{?fedora} || 0%{?rhel} > 7
BuildRequires: python2-warlock
%else
BuildRequires: python%{pyver}-sphinx
BuildRequires: python%{pyver}-openstackdocstheme
BuildRequires: python%{pyver}-keystoneauth1
BuildRequires: python%{pyver}-oslo-utils
BuildRequires: python%{pyver}-prettytable
BuildRequires: python%{pyver}-pyOpenSSL >= 17.1.0
BuildRequires: python%{pyver}-sphinxcontrib-apidoc
# Handle python2 exception
%if %{pyver} == 2
BuildRequires: python-warlock
%else
BuildRequires: python%{pyver}-warlock
%endif
%description doc
@ -112,74 +101,47 @@ This package contains auto-generated documentation.
%py_req_cleanup
%build
export PBR_VERSION=%{version}
%py2_build
%py2_build_wheel
%if 0%{?with_python3}
%py3_build
%endif
%{pyver_build}
%{pyver_build_wheel}
%install
export PBR_VERSION=%{version}
%if 0%{?with_python3}
%py3_install
mv %{buildroot}%{_bindir}/glance %{buildroot}%{_bindir}/glance-%{python3_version}
ln -s ./glance-%{python3_version} %{buildroot}%{_bindir}/glance-3
# Delete tests
rm -fr %{buildroot}%{python3_sitelib}/glanceclient/tests
%endif
%{pyver_install}
# STX: stage wheels
mkdir -p $RPM_BUILD_ROOT/wheels
install -m 644 dist/*.whl $RPM_BUILD_ROOT/wheels/
%py2_install
mv %{buildroot}%{_bindir}/glance %{buildroot}%{_bindir}/glance-%{python2_version}
ln -s ./glance-%{python2_version} %{buildroot}%{_bindir}/glance-2
ln -s ./glance-2 %{buildroot}%{_bindir}/glance
# Create a versioned binary for backwards compatibility until everything is pure py3
ln -s glance %{buildroot}%{_bindir}/glance-%{pyver}
mkdir -p %{buildroot}%{_sysconfdir}/bash_completion.d
install -pm 644 tools/glance.bash_completion \
%{buildroot}%{_sysconfdir}/bash_completion.d/glance
mkdir -p $RPM_BUILD_ROOT/wheels
install -m 644 dist/*.whl $RPM_BUILD_ROOT/wheels/
# Delete tests
rm -fr %{buildroot}%{python2_sitelib}/glanceclient/tests
rm -fr %{buildroot}%{pyver_sitelib}/glanceclient/tests
%if 0%{?with_doc}
# generate html docs
sphinx-build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
sphinx-build-%{pyver} -b html doc/source doc/build/html
# remove the sphinx-build-%{pyver} leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}
# generate man page
sphinx-build -b man doc/source doc/build/man
sphinx-build-%{pyver} -b man doc/source doc/build/man
install -p -D -m 644 doc/build/man/glance.1 %{buildroot}%{_mandir}/man1/glance.1
%endif
%files -n python2-%{sname}
%files -n python%{pyver}-%{sname}
%doc README.rst
%license LICENSE
%{python2_sitelib}/glanceclient
%{python2_sitelib}/*.egg-info
%{pyver_sitelib}/glanceclient
%{pyver_sitelib}/*.egg-info
%{_sysconfdir}/bash_completion.d
%if 0%{?with_doc}
%{_mandir}/man1/glance.1.gz
%endif
%{_bindir}/glance
%{_bindir}/glance-2
%{_bindir}/glance-%{python2_version}
%if 0%{?with_python3}
%files -n python3-%{sname}
%license LICENSE
%doc README.rst
%{python3_sitelib}/%{sname}
%{python3_sitelib}/*.egg-info
%{_sysconfdir}/bash_completion.d
%{_mandir}/man1/glance.1.gz
%{_bindir}/glance-3
%{_bindir}/glance-%{python3_version}
%endif
%{_bindir}/glance-%{pyver}
%if 0%{?with_doc}
%files doc
@ -187,7 +149,6 @@ install -p -D -m 644 doc/build/man/glance.1 %{buildroot}%{_mandir}/man1/glance.1
%license LICENSE
%endif
%package wheels
Summary: %{name} wheels
@ -198,12 +159,24 @@ Contains python wheels for %{name}
/wheels/*
%changelog
* Wed Dec 19 2018 RDO <dev@lists.rdoproject.org> 1:2.13.1-1
- Update to 2.13.1
* Wed Apr 22 2020 OSP Prod Chain <dev-null@redhat.com> 1:2.17.0-1
- Update patches
* Mon Nov 05 2018 RDO <dev@lists.rdoproject.org> 1:2.13.0-1
- Update to 2.13.0
* Wed Apr 22 2020 Cyril Roelandt <cyril@redhat.com> 1:2.17.0-0.20200310160931.40c19aa
- Delete image from specific store (rhbz#1758424)
- Pass --all-stores, --allow-failure as bool to API (rhbz#1758416)
- Add support for copy-image import method (rhbz#1758416)
- Add support for multi-store import (rhbz#1758420)
* Wed Aug 08 2018 RDO <dev@lists.rdoproject.org> 1:2.12.1-1
- Update to 2.12.1
* Tue Mar 10 2020 OSP Prod Chain <dev-null@redhat.com> 1:2.17.0-1
- Update patches
* Tue Feb 25 2020 OSP Prod Chain <dev-null@redhat.com> 1:2.17.0-1
- Cleanup session object (rhbz#1802636)
* Thu Sep 19 2019 OSP Prod Chain <dev-null@redhat.com> 1:2.17.0-1
- Update patches
* Thu Sep 19 2019 RDO <dev@lists.rdoproject.org> 1:2.17.0-1
- Update to 2.17.0