Browse code

Migrating cloud-init and its dependencies to python3

Change-Id: I7043e434324cbcab4ad4aac6267150d38b149010
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/2778
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>

Kumar Kaushik authored on 2017/05/23 07:27:16
Showing 7 changed files
... ...
@@ -1,6 +1,9 @@
1
+%{!?python2_sitelib: %define python2_sitelib %(python2 -c "from distutils.sysconfig import get_python_lib;print(get_python_lib())")}
2
+%{!?python3_sitelib: %define python3_sitelib %(python3 -c "from distutils.sysconfig import get_python_lib;print(get_python_lib())")}
3
+
1 4
 Name:           PyYAML
2 5
 Version:        3.12
3
-Release:        1%{?dist}
6
+Release:        2%{?dist}
4 7
 Summary:        YAML parser and emitter for Python
5 8
 Group:          Development/Libraries
6 9
 License:        MIT
... ...
@@ -8,14 +11,14 @@ URL:            http://pyyaml.org/
8 8
 Source0:        http://pyyaml.org/download/pyyaml/%{name}-%{version}.tar.gz
9 9
 %define sha1 PyYAML=cb7fd3e58c129494ee86e41baedfec69eb7dafbe
10 10
 
11
-BuildRequires: python2
12
-BuildRequires: python2-libs
13
-BuildRequires: python2-devel
14
-BuildRequires: libyaml-devel
11
+BuildRequires:  python2
12
+BuildRequires:  python2-libs
13
+BuildRequires:  python2-devel
14
+BuildRequires:  libyaml-devel
15 15
 
16
-Requires: python2
17
-Requires: python2-libs
18
-Requires: libyaml
16
+Requires:       python2
17
+Requires:       python2-libs
18
+Requires:       libyaml
19 19
 
20 20
 %description
21 21
 YAML is a data serialization format designed for human readability and
... ...
@@ -30,34 +33,68 @@ to represent an arbitrary Python object.
30 30
 PyYAML is applicable for a broad range of tasks from complex
31 31
 configuration files to object serialization and persistence.
32 32
 
33
+%package -n     python3-PyYAML
34
+Summary:        python3-PyYAML
35
+BuildRequires:  python3
36
+BuildRequires:  python3-devel
37
+BuildRequires:  python3-libs
38
+BuildRequires:  libyaml-devel
39
+
40
+Requires:       python3
41
+Requires:       python3-libs
42
+Requires:       libyaml
43
+
44
+%description -n python3-PyYAML
45
+Python 3 version.
46
+
47
+
33 48
 %prep
34
-%setup -q -n %{name}-%{version}
49
+%setup -q -n PyYAML-%{version}
50
+rm -rf ../p3dir
51
+cp -a . ../p3dir
35 52
 
36 53
 %build
37
-%{__python} setup.py build
38
-chmod a-x examples/yaml-highlight/yaml_hl.py
54
+python2 setup.py build
55
+pushd ../p3dir
56
+python3 setup.py build
57
+popd
39 58
 
40 59
 %install
41 60
 rm -rf $RPM_BUILD_ROOT
42 61
 mkdir -p $RPM_BUILD_ROOT/%{_bindir}
43
-%{__python} setup.py install --skip-build --root $RPM_BUILD_ROOT
62
+python2 setup.py install --skip-build --prefix=%{_prefix} --root=%{buildroot}
63
+chmod a-x examples/yaml-highlight/yaml_hl.py
64
+pushd ../p3dir
65
+python3 setup.py install --skip-build --prefix=%{_prefix} --root=%{buildroot}
66
+chmod a-x examples/yaml-highlight/yaml_hl.py
67
+popd
44 68
 
45 69
 %check
46
-python setup.py test
70
+python2 setup.py test
71
+pushd ../p3dir
72
+python3 setup.py test
73
+popd
47 74
 
48 75
 %clean
49 76
 rm -rf $RPM_BUILD_ROOT
50 77
 
51 78
 %files
79
+%defattr(-,root,root)
80
+%doc PKG-INFO README LICENSE examples
81
+%{python2_sitelib}/*
82
+
83
+%files -n python3-PyYAML
52 84
 %defattr(-,root,root,-)
53 85
 %doc PKG-INFO README LICENSE examples
54
-%{python_sitelib}/*
86
+%{python3_sitelib}/*
55 87
 
56 88
 
57 89
 %changelog
58
-*       Tue Apr 18 2017 Dheeraj Shetty <dheerajs@vmware.com> 3.12-1
59
--       Updated version to 3.12
60
-*	Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 3.11-2
61
--	GA - Bump release of all rpms
62
-* Wed Mar 04 2015 Mahmoud Bassiouny <mbassiouny@vmware.com>
63
-- Initial packaging for Photon
90
+*   Tue May 16 2017 Kumar Kaushik <kaushikk@vmware.com> 3.12-2
91
+-   Adding python3 support.
92
+*   Tue Apr 18 2017 Dheeraj Shetty <dheerajs@vmware.com> 3.12-1
93
+-   Updated version to 3.12
94
+*   Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 3.11-2
95
+-   GA - Bump release of all rpms
96
+*   Wed Mar 04 2015 Mahmoud Bassiouny <mbassiouny@vmware.com>
97
+-   Initial packaging for Photon
... ...
@@ -1,6 +1,8 @@
1
+%define python3_sitelib /usr/lib/python3.6/site-packages
2
+
1 3
 Name:           cloud-init
2 4
 Version:        0.7.9
3
-Release:        3%{?dist}
5
+Release:        4%{?dist}
4 6
 Summary:        Cloud instance init scripts
5 7
 Group:          System Environment/Base
6 8
 License:        GPLv3
... ...
@@ -18,29 +20,27 @@ Patch4:         resizePartitionUUID.patch
18 18
 Patch5:         datasource-guestinfo.patch
19 19
 Patch6:         systemd-service-changes.patch
20 20
 
21
-BuildRequires:  python2
22
-BuildRequires:  python2-libs
23
-BuildRequires:  python-setuptools
21
+BuildRequires:  python3
22
+BuildRequires:  python3-libs
24 23
 BuildRequires:  systemd
25 24
 BuildRequires:  dbus
26
-BuildRequires:  python-ipaddr
25
+BuildRequires:  python3-ipaddr
27 26
 BuildRequires:  iproute2
28 27
 BuildRequires:  automake
29 28
 
30 29
 Requires:       systemd
31 30
 Requires:       net-tools
32
-Requires:       python2
33
-Requires:       python2-libs
34
-Requires:       python-configobj
35
-Requires:       python-prettytable
36
-Requires:       python-requests
37
-Requires:       python-setuptools
38
-Requires:       PyYAML
39
-Requires:       python-jsonpatch
40
-Requires:       python-oauthlib
41
-Requires:       python-jinja2
42
-Requires:       python-markupsafe
43
-Requires:       python-six
31
+Requires:       python3
32
+Requires:       python3-libs
33
+Requires:       python3-configobj
34
+Requires:       python3-prettytable
35
+Requires:       python3-requests
36
+Requires:       python3-PyYAML
37
+Requires:       python3-jsonpatch
38
+Requires:       python3-oauthlib
39
+Requires:       python3-jinja2
40
+Requires:       python3-markupsafe
41
+Requires:       python3-six
44 42
 
45 43
 BuildArch:      noarch
46 44
 
... ...
@@ -63,20 +63,21 @@ ssh keys and to let the user run various scripts.
63 63
 find systemd -name cloud*.service | xargs sed -i s/StandardOutput=journal+console/StandardOutput=journal/g
64 64
 
65 65
 %build
66
-%{__python} setup.py build
66
+python3 setup.py build
67 67
 
68 68
 %install
69 69
 rm -rf $RPM_BUILD_ROOT
70
-%{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT --init-system systemd
70
+python3 setup.py install -O1 --skip-build --root=%{buildroot} --init-system systemd
71 71
 
72 72
 # Don't ship the tests
73
-rm -r $RPM_BUILD_ROOT%{python_sitelib}/tests
73
+rm -r %{buildroot}%{python3_sitelib}/tests
74 74
 
75
-mkdir -p $RPM_BUILD_ROOT/var/lib/cloud
75
+mkdir -p %{buildroot}/var/lib/cloud
76 76
 mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/cloud/cloud.cfg.d/
77 77
 
78 78
 # We supply our own config file since our software differs from Ubuntu's.
79
-cp -p %{SOURCE1} $RPM_BUILD_ROOT/%{_sysconfdir}/cloud/cloud.cfg
79
+cp -p %{SOURCE1} %{buildroot}/%{_sysconfdir}/cloud/cloud.cfg
80
+
80 81
 # Disable networking config by cloud-init
81 82
 cp -p %{SOURCE2} $RPM_BUILD_ROOT/%{_sysconfdir}/cloud/cloud.cfg.d/
82 83
 
... ...
@@ -154,12 +155,14 @@ rm -rf $RPM_BUILD_ROOT
154 154
 /lib/systemd/system/*
155 155
 %{_docdir}/cloud-init/*
156 156
 %{_libdir}/cloud-init/*
157
-%{python_sitelib}/*
157
+%{python3_sitelib}/*
158 158
 %{_bindir}/cloud-init*
159 159
 %dir /var/lib/cloud
160 160
 
161 161
 
162 162
 %changelog
163
+*   Mon May 22 2017 Kumar Kaushik <kaushikk@vmware.com> 0.7.9-4
164
+-   Making cloud-init to use python3.
163 165
 *   Thu May 15 2017 Anish Swaminathan <anishs@vmware.com> 0.7.9-3
164 166
 -   Disable networking config by cloud-init
165 167
 *   Thu May 04 2017 Anish Swaminathan <anishs@vmware.com> 0.7.9-2
... ...
@@ -194,7 +194,7 @@ diff -rupN cloud-init-0.7.9/cloudinit/distros/photon.py cloud-init-0.7.9-new/clo
194 194
 +        if not conf:
195 195
 +            conf = HostnameConf('')
196 196
 +        conf.set_hostname(your_hostname)
197
-+        util.write_file(out_fn, str(conf), 0644)
197
++        util.write_file(out_fn, str(conf), mode=0o644)
198 198
 +
199 199
 +    def _read_system_hostname(self):
200 200
 +        sys_hostname = self._read_hostname(self.hostname_conf_fn)
... ...
@@ -1,6 +1,9 @@
1
+%{!?python2_sitelib: %define python2_sitelib %(python2 -c "from distutils.sysconfig import get_python_lib;print(get_python_lib())")}
2
+%{!?python3_sitelib: %define python3_sitelib %(python3 -c "from distutils.sysconfig import get_python_lib;print(get_python_lib())")}
3
+
1 4
 Name:           python-configobj
2 5
 Version:        5.0.6
3
-Release:        3%{?dist}
6
+Release:        4%{?dist}
4 7
 Summary:        Config file reading, writing and validation
5 8
 License:        BSD
6 9
 Group:          Development/Languages/Python
... ...
@@ -8,37 +11,67 @@ Url:            https://pypi.python.org/packages/source/c/configobj/configobj-%{
8 8
 Source0:        configobj-%{version}.tar.gz
9 9
 %define sha1 configobj=add3ae15e3f0d2d28d37370dcad930243cb4145c
10 10
 
11
-BuildRequires: python2
12
-BuildRequires: python2-libs
13
-BuildRequires: python-setuptools
11
+BuildRequires:  python2
12
+BuildRequires:  python2-libs
13
+BuildRequires:  python-setuptools
14 14
 
15
-Requires: python-six
15
+Requires:       python-six
16 16
 
17 17
 BuildArch:      noarch
18 18
 
19 19
 %description
20 20
 ConfigObj is a simple but powerful config file reader and writer: an ini file round tripper. Its main feature is that it is very easy to use, with a straightforward programmer’s interface and a simple syntax for config files.
21 21
 
22
+%package -n     python3-configobj
23
+Summary:        python-configobj
24
+
25
+BuildRequires:  python3
26
+BuildRequires:  python3-devel
27
+BuildRequires:  python3-libs
28
+
29
+Requires:       python3-six
30
+
31
+%description -n python3-configobj
32
+Python 3 version.
33
+
22 34
 %prep
23 35
 %setup -n configobj-%{version}
36
+rm -rf ../p3dir
37
+cp -a . ../p3dir
24 38
 
25 39
 %build
26
-python setup.py build
40
+python2 setup.py build
41
+pushd ../p3dir
42
+python3 setup.py build
43
+popd
27 44
 
28 45
 %install
29
-python setup.py install --prefix=%{_prefix} --root=%{buildroot}
46
+python2 setup.py install --prefix=%{_prefix} --root=%{buildroot}
47
+pushd ../p3dir
48
+python3 setup.py install --prefix=%{_prefix} --root=%{buildroot}
49
+popd
30 50
 
31 51
 %check
32
-python validate.py
52
+python2 validate.py
53
+pushd ../p3dir
54
+python3 validate.py
55
+popd
33 56
 
34 57
 %files
35 58
 %defattr(-,root,root,-)
36
-%{python_sitelib}/*
59
+%{python2_sitelib}/*
60
+
61
+
62
+%files -n python3-configobj
63
+%defattr(-,root,root)
64
+%{python3_sitelib}/*
37 65
 
38 66
 %changelog
39
-*       Mon Oct 03 2016 ChangLee <changLee@vmware.com> 5.0.6-3
40
--       Modified %check
41
-*	Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 5.0.6-2
42
--	GA - Bump release of all rpms
43
-* Wed Mar 04 2015 Mahmoud Bassiouny <mbassiouny@vmware.com>
44
-- Initial packaging for Photon
67
+*   Mon May 15 2017 Kumar Kaushik <kaushikk@vmware.com> 5.0.6-4
68
+-   Adding python 3 support.
69
+*   Mon Oct 03 2016 ChangLee <changLee@vmware.com> 5.0.6-3
70
+-   Modified %check
71
+*   Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 5.0.6-2
72
+-   GA - Bump release of all rpms
73
+*   Wed Mar 04 2015 Mahmoud Bassiouny <mbassiouny@vmware.com>
74
+-   Initial packaging for Photon
45 75
new file mode 100755
... ...
@@ -0,0 +1,104 @@
0
+diff -ru ipaddr-2.1.11/ipaddr.py ipaddr-2.1.11-modified/ipaddr.py
1
+--- ipaddr-2.1.11/ipaddr.py	2014-01-31 13:22:32.000000000 -0800
2
+@@ -25,6 +25,11 @@
3
+ __version__ = '2.1.11'
4
+ 
5
+ import struct
6
++import sys
7
++
8
++if sys.version_info > (3,):
9
++    long = int
10
++    xrange = range
11
+ 
12
+ IPV4LENGTH = 32
13
+ IPV6LENGTH = 128
14
+@@ -1447,7 +1452,7 @@
15
+ 
16
+         try:
17
+             # Now, parse the hextets into a 128-bit integer.
18
+-            ip_int = 0L
19
++            ip_int = long(0)
20
+             for i in xrange(parts_hi):
21
+                 ip_int <<= 16
22
+                 ip_int |= self._parse_hextet(parts[i])
23
+diff -ru ipaddr-2.1.11/ipaddr_test.py ipaddr-2.1.11-modified/ipaddr_test.py
24
+--- ipaddr-2.1.11/ipaddr_test.py	2014-01-31 13:02:28.000000000 -0800
25
+@@ -21,6 +21,11 @@
26
+ import unittest
27
+ import time
28
+ import ipaddr
29
++import sys
30
++
31
++if sys.version_info > (3,):
32
++    long = int
33
++
34
+ 
35
+ # Compatibility function to cast str to bytes objects
36
+ if issubclass(ipaddr.Bytes, str):
37
+@@ -266,7 +271,7 @@
38
+                          '2001:658:22a:cafe:200::1')
39
+ 
40
+     def testGetNetmask(self):
41
+-        self.assertEqual(int(self.ipv4.netmask), 4294967040L)
42
++        self.assertEqual(int(self.ipv4.netmask), 4294967040)
43
+         self.assertEqual(str(self.ipv4.netmask), '255.255.255.0')
44
+         self.assertEqual(str(self.ipv4_hostmask.netmask), '255.0.0.0')
45
+         self.assertEqual(int(self.ipv6.netmask),
46
+@@ -283,7 +288,7 @@
47
+         self.assertEqual(ipv6_zero_netmask._prefix_from_prefix_string('0'), 0)
48
+ 
49
+     def testGetBroadcast(self):
50
+-        self.assertEqual(int(self.ipv4.broadcast), 16909311L)
51
++        self.assertEqual(int(self.ipv4.broadcast), 16909311)
52
+         self.assertEqual(str(self.ipv4.broadcast), '1.2.3.255')
53
+ 
54
+         self.assertEqual(int(self.ipv6.broadcast),
55
+@@ -1100,9 +1105,9 @@
56
+ 
57
+     def testNetworkElementCaching(self):
58
+         # V4 - make sure we're empty
59
+-        self.assertFalse(self.ipv4._cache.has_key('network'))
60
+-        self.assertFalse(self.ipv4._cache.has_key('broadcast'))
61
+-        self.assertFalse(self.ipv4._cache.has_key('hostmask'))
62
++        self.assertFalse('network' in self.ipv4._cache)
63
++        self.assertFalse('broadcast' in self.ipv4._cache)
64
++        self.assertFalse('hostmask' in self.ipv4._cache)
65
+ 
66
+         # V4 - populate and test
67
+         self.assertEqual(self.ipv4.network, ipaddr.IPv4Address('1.2.3.0'))
68
+@@ -1110,14 +1115,14 @@
69
+         self.assertEqual(self.ipv4.hostmask, ipaddr.IPv4Address('0.0.0.255'))
70
+ 
71
+         # V4 - check we're cached
72
+-        self.assertTrue(self.ipv4._cache.has_key('network'))
73
+-        self.assertTrue(self.ipv4._cache.has_key('broadcast'))
74
+-        self.assertTrue(self.ipv4._cache.has_key('hostmask'))
75
++        self.assertTrue('network' in self.ipv4._cache)
76
++        self.assertTrue('broadcast' in self.ipv4._cache)
77
++        self.assertTrue('hostmask' in self.ipv4._cache)
78
+ 
79
+         # V6 - make sure we're empty
80
+-        self.assertFalse(self.ipv6._cache.has_key('network'))
81
+-        self.assertFalse(self.ipv6._cache.has_key('broadcast'))
82
+-        self.assertFalse(self.ipv6._cache.has_key('hostmask'))
83
++        self.assertFalse('network' in self.ipv6._cache)
84
++        self.assertFalse('broadcast' in self.ipv6._cache)
85
++        self.assertFalse('hostmask' in self.ipv6._cache)
86
+ 
87
+         # V6 - populate and test
88
+         self.assertEqual(self.ipv6.network,
89
+@@ -1128,9 +1133,9 @@
90
+                          ipaddr.IPv6Address('::ffff:ffff:ffff:ffff'))
91
+ 
92
+         # V6 - check we're cached
93
+-        self.assertTrue(self.ipv6._cache.has_key('network'))
94
+-        self.assertTrue(self.ipv6._cache.has_key('broadcast'))
95
+-        self.assertTrue(self.ipv6._cache.has_key('hostmask'))
96
++        self.assertTrue('network' in self.ipv6._cache)
97
++        self.assertTrue('broadcast' in self.ipv6._cache)
98
++        self.assertTrue('hostmask' in self.ipv6._cache)
99
+ 
100
+     def testTeredo(self):
101
+         # stolen from wikipedia
... ...
@@ -1,45 +1,79 @@
1
+%{!?python2_sitelib: %define python2_sitelib %(python2 -c "from distutils.sysconfig import get_python_lib;print(get_python_lib())")}
2
+%{!?python3_sitelib: %define python3_sitelib %(python3 -c "from distutils.sysconfig import get_python_lib;print(get_python_lib())")}
3
+
1 4
 Name:           python-ipaddr
2 5
 Version:        2.1.11
3
-Release:        3%{?dist}
6
+Release:        4%{?dist}
4 7
 Url:            https://github.com/google/ipaddr-py
5 8
 Summary:        Google's Python IP address manipulation library
6 9
 License:        Apache2
7 10
 Group:          Development/Languages/Python
8 11
 Source0:        https://pypi.python.org/packages/source/i/ipaddr/ipaddr-%{version}.tar.gz
9 12
 %define sha1 ipaddr=f9a16ddb3cf774b8dcf8894c2f4295c4e17d0ed3
13
+Patch0:         ipaddr-python3-compatibility.patch
10 14
 
11
-BuildRequires: python2
12
-BuildRequires: python2-libs
13
-BuildRequires: python-setuptools
15
+BuildRequires:  python2
16
+BuildRequires:  python2-libs
17
+BuildRequires:  python-setuptools
14 18
 
15 19
 Requires:       python2
16
-Requires:		python2-libs
20
+Requires:	python2-libs
17 21
 
18 22
 BuildArch:      noarch
19 23
 
20 24
 %description
21 25
 ipaddr.py is a library for working with IP addresses, both IPv4 and IPv6. It was developed by Google for internal use, and is now open source.
22 26
 
27
+%package -n     python3-ipaddr
28
+Summary:        python-ipaddr
29
+BuildRequires:  python3
30
+BuildRequires:  python3-devel
31
+BuildRequires:  python3-libs
32
+
33
+Requires:       python3
34
+Requires:       python3-libs
35
+
36
+%description -n python3-ipaddr
37
+Python 3 version.
38
+
23 39
 %prep
24 40
 %setup -q -n ipaddr-%{version}
41
+%patch0 -p1
42
+rm -rf ../p3dir
43
+cp -a . ../p3dir
25 44
 
26 45
 %build
27
-python setup.py build
46
+python2 setup.py build
47
+pushd ../p3dir
48
+python3 setup.py build
49
+popd
28 50
 
29 51
 %install
30
-python setup.py install --prefix=%{_prefix} --root=%{buildroot}
52
+python2 setup.py install --prefix=%{_prefix} --root=%{buildroot}
53
+pushd ../p3dir
54
+python3 setup.py install --prefix=%{_prefix} --root=%{buildroot}
55
+popd
31 56
 
32 57
 %check
33
-python ipaddr_test.py
58
+python2 ipaddr_test.py
59
+pushd ../p3dir
60
+python3 ipaddr_test.py
61
+popd
34 62
 
35 63
 %files
36 64
 %defattr(-,root,root)
37
-%{python_sitelib}/*
65
+%{python2_sitelib}/*
66
+
67
+%files -n python3-ipaddr
68
+%defattr(-,root,root,-)
69
+%{python3_sitelib}/*
38 70
 
39 71
 %changelog
40
-*       Mon Oct 03 2016 ChangLee <changLee@vmware.com> 2.1.11-3
41
--       Modified %check
42
-*	Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 2.1.11-2
43
--	GA - Bump release of all rpms
44
-* Tue Oct 27 2015 Mahmoud Bassiouny <mbassiouny@vmware.com>
45
-- Initial packaging for Photon
72
+*   Tue May 16 2017 Kumar Kaushik <kaushikk@vmware.com> 2.1.11-4
73
+-   Adding python 3 support.
74
+*   Mon Oct 03 2016 ChangLee <changLee@vmware.com> 2.1.11-3
75
+-   Modified %check
76
+*   Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 2.1.11-2
77
+-   GA - Bump release of all rpms
78
+*   Tue Oct 27 2015 Mahmoud Bassiouny <mbassiouny@vmware.com>
79
+-   Initial packaging for Photon
... ...
@@ -1,6 +1,9 @@
1
+%{!?python2_sitelib: %define python2_sitelib %(python2 -c "from distutils.sysconfig import get_python_lib;print(get_python_lib())")}
2
+%{!?python3_sitelib: %define python3_sitelib %(python3 -c "from distutils.sysconfig import get_python_lib;print(get_python_lib())")}
3
+
1 4
 Name:           python-prettytable
2 5
 Version:        0.7.2
3
-Release:        3%{?dist}
6
+Release:        4%{?dist}
4 7
 Summary:        Library for displaying tabular data in a visually appealing ASCII format
5 8
 License:        BSD-2-Clause
6 9
 Group:          Development/Languages/Python
... ...
@@ -8,12 +11,12 @@ Url:            http://code.google.com/p/prettytable/
8 8
 Source0:        prettytable-%{version}.tar.gz
9 9
 %define sha1 prettytable=b7d0bf0feee0d23108a044ffae44aff5c5935250
10 10
 
11
-BuildRequires: python2
12
-BuildRequires: python2-libs
13
-BuildRequires: python-setuptools
11
+BuildRequires:  python2
12
+BuildRequires:  python2-libs
13
+BuildRequires:  python-setuptools
14 14
 
15
-Requires: python2
16
-Requires: python2-libs
15
+Requires:       python2
16
+Requires:       python2-libs
17 17
 
18 18
 BuildArch:      noarch
19 19
 
... ...
@@ -25,26 +28,58 @@ selection of which columns are to be printed, independent alignment of columns
25 25
 (left or right justified or centred) and printing of "sub-tables" by
26 26
 specifying a row range.
27 27
 
28
+
29
+%package -n     python3-prettytable
30
+Summary:        python-prettytable
31
+
32
+BuildRequires:  python3
33
+BuildRequires:  python3-devel
34
+BuildRequires:  python3-libs
35
+
36
+Requires:       python3
37
+Requires:       python3-libs
38
+
39
+%description -n python3-prettytable
40
+Python 3 version.
41
+
28 42
 %prep
29 43
 %setup -n prettytable-%{version}
44
+rm -rf ../p3dir
45
+cp -a . ../p3dir
30 46
 
31 47
 %build
32
-python setup.py build
48
+python2 setup.py build
49
+pushd ../p3dir
50
+python3 setup.py build
51
+popd
33 52
 
34 53
 %install
35
-python setup.py install --prefix=%{_prefix} --root=%{buildroot}
54
+python2 setup.py install --prefix=%{_prefix} --root=%{buildroot}
55
+pushd ../p3dir
56
+python3 setup.py install --prefix=%{_prefix} --root=%{buildroot}
57
+popd
36 58
 
37 59
 %check
38
-python prettytable_test.py
60
+python2 prettytable_test.py
61
+pushd ../p3dir
62
+python3 prettytable_test.py
63
+popd
39 64
 
40 65
 %files
66
+%defattr(-,root,root)
67
+%{python2_sitelib}/*
68
+
69
+%files -n python3-prettytable
41 70
 %defattr(-,root,root,-)
42
-%{python_sitelib}/*
71
+%{python3_sitelib}/*
72
+
43 73
 
44 74
 %changelog
45
-*       Mon Oct 04 2016 ChangLee <changlee@vmware.com> 0.7.2-3
46
--       Modified %check
47
-*	Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 0.7.2-2
48
--	GA - Bump release of all rpms
49
-* Wed Mar 04 2015 Mahmoud Bassiouny <mbassiouny@vmware.com>
50
-- Initial packaging for Photon
75
+*   Tue May 16 2017 Kumar Kaushik <kaushikk@vmware.com> 0.7.2-4
76
+-   Adding python3 support.
77
+*   Mon Oct 04 2016 ChangLee <changlee@vmware.com> 0.7.2-3
78
+-   Modified %check
79
+*   Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 0.7.2-2
80
+-   GA - Bump release of all rpms
81
+*   Wed Mar 04 2015 Mahmoud Bassiouny <mbassiouny@vmware.com>
82
+-   Initial packaging for Photon