From 2af55b2805ee6f9239ac03fc8e50850186ad019f Mon Sep 17 00:00:00 2001
From: Chandan Kumar <chkumar246@gmail.com>
Date: Mon, 7 Sep 2015 17:41:09 +0530
Subject: [PATCH] Added python2 and python3 subpackage

---
 python-oslo-utils.spec | 107 ++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 98 insertions(+), 9 deletions(-)

diff --git a/python-oslo-utils.spec b/python-oslo-utils.spec
index 6d475c1..71f60a2 100644
--- a/python-oslo-utils.spec
+++ b/python-oslo-utils.spec
@@ -1,10 +1,16 @@
 %global pypi_name oslo.utils
 
+%{!?_licensedir:%global license %%doc}
+
+%if 0%{?fedora}
+%global with_python3 1
+%endif
+
 %{!?upstream_version: %global upstream_version %{version}%{?milestone}}
 
 Name:           python-oslo-utils
 Version:        2.4.0
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        OpenStack Oslo Utility library
 
 License:        ASL 2.0
@@ -12,6 +18,19 @@ URL:            http://launchpad.net/oslo
 Source0:        https://pypi.python.org/packages/source/o/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
 BuildArch:      noarch
 
+%description
+The OpenStack Oslo Utility library.
+* Documentation: http://docs.openstack.org/developer/oslo.utils
+* Source: http://git.openstack.org/cgit/openstack/oslo.utils
+* Bugs: http://bugs.launchpad.net/oslo
+
+%package -n python2-oslo-utils
+Summary:        OpenStack Oslo Utility library
+%{?python_provide:%python_provide python2-oslo-utils}
+# python_provide does not exist in CBS Cloud buildroot
+Provides:       python-oslo-utils = %{version}-%{release}
+Obsoletes:      python-oslo-utils < 2.4.0-2
+
 BuildRequires:  python2-devel
 BuildRequires:  python-pbr
 
@@ -26,17 +45,18 @@ Requires:       python-debtcollector >= 0.3.0
 Requires:       pytz
 Requires:       python-monotonic
 
-
-%description
+%description -n python2-oslo-utils
 The OpenStack Oslo Utility library.
 * Documentation: http://docs.openstack.org/developer/oslo.utils
 * Source: http://git.openstack.org/cgit/openstack/oslo.utils
 * Bugs: http://bugs.launchpad.net/oslo
 
-
-%package doc
+%package -n python2-oslo-utils-doc
 Summary:    Documentation for the Oslo Utility library
-Group:      Documentation
+%{?python_provide:%python_provide python2-oslo-utils-doc}
+# python_provide does not exist in CBS Cloud buildroot
+Provides:       python-oslo-utils-doc = %{version}-%{release}
+Obsoletes:      python-oslo-utils-doc < 2.4.0-2
 
 BuildRequires:  python-sphinx
 BuildRequires:  python-oslo-sphinx
@@ -46,9 +66,52 @@ BuildRequires:  python-debtcollector
 BuildRequires:  python-oslo-i18n
 BuildRequires:  python-netaddr
 
-%description doc
+%description -n python2-oslo-utils-doc
 Documentation for the Oslo Utility library.
 
+# python3 subpackage
+%if 0%{?with_python3}
+%package -n python3-oslo-utils
+Summary:        OpenStack Oslo Utility library
+%{?python_provide:%python_provide python3-oslo-utils}
+
+BuildRequires:  python3-devel
+BuildRequires:  python3-pbr
+
+Requires:       python3-oslo-config
+Requires:       python3-oslo-i18n
+Requires:       python3-babel
+Requires:       python3-iso8601
+Requires:       python3-six >= 1.9.0
+Requires:       python3-netaddr >= 0.7.12
+Requires:       python3-netifaces >= 0.10.4
+Requires:       python3-debtcollector >= 0.3.0
+Requires:       python3-pytz
+Requires:       python3-monotonic
+
+%description -n python3-oslo-utils
+The OpenStack Oslo Utility library.
+* Documentation: http://docs.openstack.org/developer/oslo.utils
+* Source: http://git.openstack.org/cgit/openstack/oslo.utils
+* Bugs: http://bugs.launchpad.net/oslo
+%endif
+
+%if 0%{?with_python3}
+%package -n python3-oslo-utils-doc
+Summary:    Documentation for the Oslo Utility library
+%{?python_provide:%python_provide python3-oslo-utils-doc}
+
+BuildRequires:  python3-sphinx
+BuildRequires:  python3-oslo-sphinx
+# for API autodoc
+BuildRequires:  python3-netifaces
+BuildRequires:  python3-debtcollector
+BuildRequires:  python3-oslo-i18n
+BuildRequires:  python3-netaddr
+
+%description -n python3-oslo-utils-doc
+Documentation for the Oslo Utility library.
+%endif
 
 %prep
 %setup -q -n %{pypi_name}-%{upstream_version}
@@ -65,22 +128,48 @@ sphinx-build doc/source html
 # remove the sphinx-build leftovers
 rm -rf html/.{doctrees,buildinfo}
 
+%if 0%{?with_python3}
+%{__python3} setup.py build
+sphinx-build-3 doc/source html
+# Fix hidden-file-or-dir warnings
+rm -fr doc/build/html/.buildinfo
+%endif
 
 %install
 %{__python2} setup.py install --skip-build --root %{buildroot}
 
+%if 0%{?with_python3}
+%{__python3} setup.py install --skip-build --root %{buildroot}
+%endif
 
-%files
+%files -n python2-oslo-utils
 %doc README.rst
 %license LICENSE
 %{python2_sitelib}/oslo_utils
 %{python2_sitelib}/*.egg-info
 
-%files doc
+%files -n python2-oslo-utils-doc
 %doc html
 %license LICENSE
 
+%if 0%{?with_python3}
+%files -n python3-oslo-utils
+%doc README.rst
+%license LICENSE
+%{python3_sitelib}/oslo_utils
+%{python3_sitelib}/*.egg-info
+%endif
+
+%if 0%{?with_python3}
+%files -n python3-oslo-utils-doc
+%doc html
+%license LICENSE
+%endif
+
 %changelog
+* Mon Sep 07 2015 Chandan Kumar <chkumar246@gmail.com> 2.4.0-2
+- Added python2 and python3 subpackages
+
 * Thu Sep 03 2015 Alan Pevec <alan.pevec@redhat.com> 2.4.0-1
 - Update to upstream 2.4.0
 
-- 
2.4.0

