Skip to content

Commit b22e4f2

Browse files
committed
Drop support for python 2
python2 will be end of life by the time of the next libvirt release. All our supported build targets, including CentOS7, have a python3 build available. Reviewed-by: Michal Privoznik <[email protected]> Signed-off-by: Daniel P. Berrangé <[email protected]>
1 parent e3fa4f2 commit b22e4f2

26 files changed

+71
-381
lines changed

Diff for: .travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ os: linux
33
dist: xenial
44

55
python:
6-
- 2.7
76
- 3.6
87

98
env:

Diff for: examples/consolecallback.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# consolecallback - provide a persistent console that survives guest reboots
33

44
import sys, os, logging, libvirt, tty, termios, atexit

Diff for: examples/dhcpleases.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# netdhcpleases - print leases info for given virtual network
33

44
import libvirt

Diff for: examples/dominfo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# dominfo - print some information about a domain
33

44
import libvirt

Diff for: examples/domipaddrs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# domipaddrs - print domain interfaces along with their MAC and IP addresses
33

44
import libvirt

Diff for: examples/domrestore.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# domstart - make sure a given domU is running, if not start it
33

44
import libvirt

Diff for: examples/domsave.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# domstart - make sure a given domU is running, if not start it
33

44
import libvirt

Diff for: examples/domstart.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# domstart - make sure a given domU is running, if not start it
33

44
import libvirt

Diff for: examples/esxlist.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# esxlist - list active domains of an ESX host and print some info.
33
# also demonstrates how to use the libvirt.openAuth() method
44

Diff for: examples/event-test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
#
33
#
44
#

Diff for: examples/guest-vcpus/guest-vcpu-daemon.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
import libvirt
44
import threading

Diff for: examples/guest-vcpus/guest-vcpu.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
import libvirt
44
import sys

Diff for: examples/nodestats.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# Print some host NUMA node statistics
33
#
44
# Authors:

Diff for: examples/sparsestream.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# Example of sparse streams usage
33
#
44
# Authors:

Diff for: examples/topology.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# Parse topology information from the capabilities XML and use
33
# them to calculate host topology
44
#

Diff for: generator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
#
33
# generate python wrappers from the XML API description
44
#

Diff for: libvirt-lxc-override.c

+10-41
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
* entry points where an automatically generated stub is
55
* unpractical
66
*
7-
* Copyright (C) 2012-2013 Red Hat, Inc.
7+
* Copyright (C) 2012-2019 Red Hat, Inc.
88
*
99
* Daniel Veillard <[email protected]>
1010
*/
1111

1212
/* Horrible kludge to work around even more horrible name-space pollution
13-
via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
13+
via Python.h. That file includes /usr/include/python3.x/pyconfig*.h,
1414
which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
1515
#undef HAVE_PTHREAD_H
1616

@@ -21,18 +21,10 @@
2121
#include "libvirt-utils.h"
2222
#include "build/libvirt-lxc.h"
2323

24-
#if PY_MAJOR_VERSION > 2
25-
# ifndef __CYGWIN__
24+
#ifndef __CYGWIN__
2625
extern PyObject *PyInit_libvirtmod_lxc(void);
27-
# else
28-
extern PyObject *PyInit_cygvirtmod_lxc(void);
29-
# endif
3026
#else
31-
# ifndef __CYGWIN__
32-
extern void initlibvirtmod_lxc(void);
33-
# else
34-
extern void initcygvirtmod_lxc(void);
35-
# endif
27+
extern PyObject *PyInit_cygvirtmod_lxc(void);
3628
#endif
3729

3830
#if 0
@@ -107,14 +99,13 @@ static PyMethodDef libvirtLxcMethods[] = {
10799
{NULL, NULL, 0, NULL}
108100
};
109101

110-
#if PY_MAJOR_VERSION > 2
111102
static struct PyModuleDef moduledef = {
112103
PyModuleDef_HEAD_INIT,
113-
# ifndef __CYGWIN__
104+
#ifndef __CYGWIN__
114105
"libvirtmod_lxc",
115-
# else
106+
#else
116107
"cygvirtmod_lxc",
117-
# endif
108+
#endif
118109
NULL,
119110
-1,
120111
libvirtLxcMethods,
@@ -125,11 +116,11 @@ static struct PyModuleDef moduledef = {
125116
};
126117

127118
PyObject *
128-
# ifndef __CYGWIN__
119+
#ifndef __CYGWIN__
129120
PyInit_libvirtmod_lxc
130-
# else
121+
#else
131122
PyInit_cygvirtmod_lxc
132-
# endif
123+
#endif
133124
(void)
134125
{
135126
PyObject *module;
@@ -141,25 +132,3 @@ PyInit_cygvirtmod_lxc
141132

142133
return module;
143134
}
144-
#else /* ! PY_MAJOR_VERSION > 2 */
145-
void
146-
# ifndef __CYGWIN__
147-
initlibvirtmod_lxc
148-
# else
149-
initcygvirtmod_lxc
150-
# endif
151-
(void)
152-
{
153-
if (virInitialize() < 0)
154-
return;
155-
156-
/* initialize the python extension module */
157-
Py_InitModule((char *)
158-
# ifndef __CYGWIN__
159-
"libvirtmod_lxc",
160-
# else
161-
"cygvirtmod_lxc",
162-
# endif
163-
libvirtLxcMethods);
164-
}
165-
#endif /* ! PY_MAJOR_VERSION > 2 */

Diff for: libvirt-override.c

+10-41
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
* entry points where an automatically generated stub is
55
* unpractical
66
*
7-
* Copyright (C) 2005, 2007-2015 Red Hat, Inc.
7+
* Copyright (C) 2005-2019 Red Hat, Inc.
88
*
99
* Daniel Veillard <[email protected]>
1010
*/
1111

1212
/* Horrible kludge to work around even more horrible name-space pollution
13-
via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
13+
via Python.h. That file includes /usr/include/python3.x/pyconfig*.h,
1414
which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
1515
#undef HAVE_PTHREAD_H
1616

@@ -25,18 +25,10 @@
2525
#include "build/libvirt.h"
2626
#include "libvirt-utils.h"
2727

28-
#if PY_MAJOR_VERSION > 2
29-
# ifndef __CYGWIN__
28+
#ifndef __CYGWIN__
3029
extern PyObject *PyInit_libvirtmod(void);
31-
# else
32-
extern PyObject *PyInit_cygvirtmod(void);
33-
# endif
3430
#else
35-
# ifndef __CYGWIN__
36-
extern void initlibvirtmod(void);
37-
# else
38-
extern void initcygvirtmod(void);
39-
# endif
31+
extern PyObject *PyInit_cygvirtmod(void);
4032
#endif
4133

4234
#if 0
@@ -10553,14 +10545,13 @@ static PyMethodDef libvirtMethods[] = {
1055310545
{NULL, NULL, 0, NULL}
1055410546
};
1055510547

10556-
#if PY_MAJOR_VERSION > 2
1055710548
static struct PyModuleDef moduledef = {
1055810549
PyModuleDef_HEAD_INIT,
10559-
# ifndef __CYGWIN__
10550+
#ifndef __CYGWIN__
1056010551
"libvirtmod",
10561-
# else
10552+
#else
1056210553
"cygvirtmod",
10563-
# endif
10554+
#endif
1056410555
NULL,
1056510556
-1,
1056610557
libvirtMethods,
@@ -10571,11 +10562,11 @@ static struct PyModuleDef moduledef = {
1057110562
};
1057210563

1057310564
PyObject *
10574-
# ifndef __CYGWIN__
10565+
#ifndef __CYGWIN__
1057510566
PyInit_libvirtmod
10576-
# else
10567+
#else
1057710568
PyInit_cygvirtmod
10578-
# endif
10569+
#endif
1057910570
(void)
1058010571
{
1058110572
PyObject *module;
@@ -10587,25 +10578,3 @@ PyInit_cygvirtmod
1058710578

1058810579
return module;
1058910580
}
10590-
#else /* ! PY_MAJOR_VERSION > 2 */
10591-
void
10592-
# ifndef __CYGWIN__
10593-
initlibvirtmod
10594-
# else
10595-
initcygvirtmod
10596-
# endif
10597-
(void)
10598-
{
10599-
if (virInitialize() < 0)
10600-
return;
10601-
10602-
/* initialize the python extension module */
10603-
Py_InitModule((char *)
10604-
# ifndef __CYGWIN__
10605-
"libvirtmod",
10606-
# else
10607-
"cygvirtmod",
10608-
# endif
10609-
libvirtMethods);
10610-
}
10611-
#endif /* ! PY_MAJOR_VERSION > 2 */

0 commit comments

Comments
 (0)