From 6a7ce2523c922159168161c04f16f90b7f07d3fb913e8e0d4042e0e956a035f5 Mon Sep 17 00:00:00 2001 From: James Fehlig Date: Thu, 6 Feb 2020 23:33:50 +0000 Subject: [PATCH 1/2] Accepting request 770735 from home:jfehlig:branches:Virtualization Drop py2 support - Stop building for python2 Dropped patches: revert-b22e4f24.patch OBS-URL: https://build.opensuse.org/request/show/770735 OBS-URL: https://build.opensuse.org/package/show/Virtualization/python-libvirt-python?expand=0&rev=65 --- python-libvirt-python.changes | 6 + python-libvirt-python.spec | 5 +- revert-b22e4f24.patch | 855 ---------------------------------- 3 files changed, 9 insertions(+), 857 deletions(-) delete mode 100644 revert-b22e4f24.patch diff --git a/python-libvirt-python.changes b/python-libvirt-python.changes index 7cfd2ff..adb3fc9 100644 --- a/python-libvirt-python.changes +++ b/python-libvirt-python.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Feb 6 23:16:01 UTC 2020 - James Fehlig + +- Stop building for python2 + Dropped patches: revert-b22e4f24.patch + ------------------------------------------------------------------- Wed Jan 15 19:33:21 UTC 2020 - James Fehlig diff --git a/python-libvirt-python.spec b/python-libvirt-python.spec index bf21094..ee6fcb6 100644 --- a/python-libvirt-python.spec +++ b/python-libvirt-python.spec @@ -16,6 +16,9 @@ # +# No longer build for python2. Support was dropped upstream in the 6.0.0 release +%define skip_python2 1 + %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define srcname libvirt-python Name: python-libvirt-python @@ -28,7 +31,6 @@ Group: Development/Languages/Python Source0: %{srcname}-%{version}.tar.gz Source1: %{srcname}-%{version}.tar.gz.asc Source2: python-libvirt-python.keyring -Patch0: revert-b22e4f24.patch BuildRequires: fdupes BuildRequires: libvirt-devel = %{version} BuildRequires: python-rpm-macros @@ -50,7 +52,6 @@ of recent versions of Linux (v2.6.20+). %prep %setup -q -n %{srcname}-%{version} -%patch0 -p1 # Unset execute bit for example scripts; it can introduce spurious # RPM dependencies, like /usr/bin/python which can pull in python2 diff --git a/revert-b22e4f24.patch b/revert-b22e4f24.patch deleted file mode 100644 index 445d520..0000000 --- a/revert-b22e4f24.patch +++ /dev/null @@ -1,855 +0,0 @@ -commit 5d143f0c339ce1b05b43cba9b45a549a0f225463 -Author: Jim Fehlig -Date: Thu Jan 16 15:34:22 2020 -0700 - - Revert "Drop support for python 2" - - This reverts commit b22e4f2441078aec048b9503fde2b45e78710ce1. - - On SUSE, we'll keep python2 binding for a bit longer. - -Index: libvirt-python-6.0.0/examples/consolecallback.py -=================================================================== ---- libvirt-python-6.0.0.orig/examples/consolecallback.py -+++ libvirt-python-6.0.0/examples/consolecallback.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - # consolecallback - provide a persistent console that survives guest reboots - - import sys, os, logging, libvirt, tty, termios, atexit -Index: libvirt-python-6.0.0/examples/dominfo.py -=================================================================== ---- libvirt-python-6.0.0.orig/examples/dominfo.py -+++ libvirt-python-6.0.0/examples/dominfo.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - # dominfo - print some information about a domain - - import libvirt -Index: libvirt-python-6.0.0/examples/domipaddrs.py -=================================================================== ---- libvirt-python-6.0.0.orig/examples/domipaddrs.py -+++ libvirt-python-6.0.0/examples/domipaddrs.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - # domipaddrs - print domain interfaces along with their MAC and IP addresses - - import libvirt -Index: libvirt-python-6.0.0/examples/domrestore.py -=================================================================== ---- libvirt-python-6.0.0.orig/examples/domrestore.py -+++ libvirt-python-6.0.0/examples/domrestore.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - # domstart - make sure a given domU is running, if not start it - - import libvirt -Index: libvirt-python-6.0.0/examples/domsave.py -=================================================================== ---- libvirt-python-6.0.0.orig/examples/domsave.py -+++ libvirt-python-6.0.0/examples/domsave.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - # domstart - make sure a given domU is running, if not start it - - import libvirt -Index: libvirt-python-6.0.0/examples/domstart.py -=================================================================== ---- libvirt-python-6.0.0.orig/examples/domstart.py -+++ libvirt-python-6.0.0/examples/domstart.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - # domstart - make sure a given domU is running, if not start it - - import libvirt -Index: libvirt-python-6.0.0/examples/esxlist.py -=================================================================== ---- libvirt-python-6.0.0.orig/examples/esxlist.py -+++ libvirt-python-6.0.0/examples/esxlist.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - # esxlist - list active domains of an ESX host and print some info. - # also demonstrates how to use the libvirt.openAuth() method - -Index: libvirt-python-6.0.0/examples/event-test.py -=================================================================== ---- libvirt-python-6.0.0.orig/examples/event-test.py -+++ libvirt-python-6.0.0/examples/event-test.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - # - # - # -Index: libvirt-python-6.0.0/examples/guest-vcpus/guest-vcpu-daemon.py -=================================================================== ---- libvirt-python-6.0.0.orig/examples/guest-vcpus/guest-vcpu-daemon.py -+++ libvirt-python-6.0.0/examples/guest-vcpus/guest-vcpu-daemon.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - - import libvirt - import threading -Index: libvirt-python-6.0.0/examples/guest-vcpus/guest-vcpu.py -=================================================================== ---- libvirt-python-6.0.0.orig/examples/guest-vcpus/guest-vcpu.py -+++ libvirt-python-6.0.0/examples/guest-vcpus/guest-vcpu.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - - import libvirt - import sys -Index: libvirt-python-6.0.0/examples/nodestats.py -=================================================================== ---- libvirt-python-6.0.0.orig/examples/nodestats.py -+++ libvirt-python-6.0.0/examples/nodestats.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - # Print some host NUMA node statistics - # - # Authors: -Index: libvirt-python-6.0.0/examples/topology.py -=================================================================== ---- libvirt-python-6.0.0.orig/examples/topology.py -+++ libvirt-python-6.0.0/examples/topology.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - # Parse topology information from the capabilities XML and use - # them to calculate host topology - # -Index: libvirt-python-6.0.0/generator.py -=================================================================== ---- libvirt-python-6.0.0.orig/generator.py -+++ libvirt-python-6.0.0/generator.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - # - # generate python wrappers from the XML API description - # -Index: libvirt-python-6.0.0/libvirt-lxc-override.c -=================================================================== ---- libvirt-python-6.0.0.orig/libvirt-lxc-override.c -+++ libvirt-python-6.0.0/libvirt-lxc-override.c -@@ -4,13 +4,13 @@ - * entry points where an automatically generated stub is - * unpractical - * -- * Copyright (C) 2012-2019 Red Hat, Inc. -+ * Copyright (C) 2012-2013 Red Hat, Inc. - * - * Daniel Veillard - */ - - /* Horrible kludge to work around even more horrible name-space pollution -- via Python.h. That file includes /usr/include/python3.x/pyconfig*.h, -+ via Python.h. That file includes /usr/include/python2.5/pyconfig*.h, - which has over 180 autoconf-style HAVE_* definitions. Shame on them. */ - #undef HAVE_PTHREAD_H - -@@ -21,10 +21,18 @@ - #include "libvirt-utils.h" - #include "build/libvirt-lxc.h" - --#ifndef __CYGWIN__ -+#if PY_MAJOR_VERSION > 2 -+# ifndef __CYGWIN__ - extern PyObject *PyInit_libvirtmod_lxc(void); --#else -+# else - extern PyObject *PyInit_cygvirtmod_lxc(void); -+# endif -+#else -+# ifndef __CYGWIN__ -+extern void initlibvirtmod_lxc(void); -+# else -+extern void initcygvirtmod_lxc(void); -+# endif - #endif - - #if 0 -@@ -99,13 +107,14 @@ static PyMethodDef libvirtLxcMethods[] = - {NULL, NULL, 0, NULL} - }; - -+#if PY_MAJOR_VERSION > 2 - static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, --#ifndef __CYGWIN__ -+# ifndef __CYGWIN__ - "libvirtmod_lxc", --#else -+# else - "cygvirtmod_lxc", --#endif -+# endif - NULL, - -1, - libvirtLxcMethods, -@@ -116,11 +125,11 @@ static struct PyModuleDef moduledef = { - }; - - PyObject * --#ifndef __CYGWIN__ -+# ifndef __CYGWIN__ - PyInit_libvirtmod_lxc --#else -+# else - PyInit_cygvirtmod_lxc --#endif -+# endif - (void) - { - PyObject *module; -@@ -132,3 +141,25 @@ PyInit_cygvirtmod_lxc - - return module; - } -+#else /* ! PY_MAJOR_VERSION > 2 */ -+void -+# ifndef __CYGWIN__ -+initlibvirtmod_lxc -+# else -+initcygvirtmod_lxc -+# endif -+(void) -+{ -+ if (virInitialize() < 0) -+ return; -+ -+ /* initialize the python extension module */ -+ Py_InitModule((char *) -+# ifndef __CYGWIN__ -+ "libvirtmod_lxc", -+# else -+ "cygvirtmod_lxc", -+# endif -+ libvirtLxcMethods); -+} -+#endif /* ! PY_MAJOR_VERSION > 2 */ -Index: libvirt-python-6.0.0/libvirt-override.c -=================================================================== ---- libvirt-python-6.0.0.orig/libvirt-override.c -+++ libvirt-python-6.0.0/libvirt-override.c -@@ -4,13 +4,13 @@ - * entry points where an automatically generated stub is - * unpractical - * -- * Copyright (C) 2005-2019 Red Hat, Inc. -+ * Copyright (C) 2005, 2007-2015 Red Hat, Inc. - * - * Daniel Veillard - */ - - /* Horrible kludge to work around even more horrible name-space pollution -- via Python.h. That file includes /usr/include/python3.x/pyconfig*.h, -+ via Python.h. That file includes /usr/include/python2.5/pyconfig*.h, - which has over 180 autoconf-style HAVE_* definitions. Shame on them. */ - #undef HAVE_PTHREAD_H - -@@ -25,10 +25,18 @@ - #include "build/libvirt.h" - #include "libvirt-utils.h" - --#ifndef __CYGWIN__ -+#if PY_MAJOR_VERSION > 2 -+# ifndef __CYGWIN__ - extern PyObject *PyInit_libvirtmod(void); --#else -+# else - extern PyObject *PyInit_cygvirtmod(void); -+# endif -+#else -+# ifndef __CYGWIN__ -+extern void initlibvirtmod(void); -+# else -+extern void initcygvirtmod(void); -+# endif - #endif - - #if 0 -@@ -10628,13 +10636,14 @@ static PyMethodDef libvirtMethods[] = { - {NULL, NULL, 0, NULL} - }; - -+#if PY_MAJOR_VERSION > 2 - static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, --#ifndef __CYGWIN__ -+# ifndef __CYGWIN__ - "libvirtmod", --#else -+# else - "cygvirtmod", --#endif -+# endif - NULL, - -1, - libvirtMethods, -@@ -10645,11 +10654,11 @@ static struct PyModuleDef moduledef = { - }; - - PyObject * --#ifndef __CYGWIN__ -+# ifndef __CYGWIN__ - PyInit_libvirtmod --#else -+# else - PyInit_cygvirtmod --#endif -+# endif - (void) - { - PyObject *module; -@@ -10661,3 +10670,25 @@ PyInit_cygvirtmod - - return module; - } -+#else /* ! PY_MAJOR_VERSION > 2 */ -+void -+# ifndef __CYGWIN__ -+initlibvirtmod -+# else -+initcygvirtmod -+# endif -+(void) -+{ -+ if (virInitialize() < 0) -+ return; -+ -+ /* initialize the python extension module */ -+ Py_InitModule((char *) -+# ifndef __CYGWIN__ -+ "libvirtmod", -+# else -+ "cygvirtmod", -+# endif -+ libvirtMethods); -+} -+#endif /* ! PY_MAJOR_VERSION > 2 */ -Index: libvirt-python-6.0.0/libvirt-qemu-override.c -=================================================================== ---- libvirt-python-6.0.0.orig/libvirt-qemu-override.c -+++ libvirt-python-6.0.0/libvirt-qemu-override.c -@@ -4,13 +4,13 @@ - * entry points where an automatically generated stub is - * unpractical - * -- * Copyright (C) 2011-2019 Red Hat, Inc. -+ * Copyright (C) 2011-2014 Red Hat, Inc. - * - * Daniel Veillard - */ - - /* Horrible kludge to work around even more horrible name-space pollution -- via Python.h. That file includes /usr/include/python3.x/pyconfig*.h, -+ via Python.h. That file includes /usr/include/python2.5/pyconfig*.h, - which has over 180 autoconf-style HAVE_* definitions. Shame on them. */ - #undef HAVE_PTHREAD_H - -@@ -21,10 +21,18 @@ - #include "libvirt-utils.h" - #include "build/libvirt-qemu.h" - --#ifndef __CYGWIN__ -+#if PY_MAJOR_VERSION > 2 -+# ifndef __CYGWIN__ - extern PyObject *PyInit_libvirtmod_qemu(void); --#else -+# else - extern PyObject *PyInit_cygvirtmod_qemu(void); -+# endif -+#else -+# ifndef __CYGWIN__ -+extern void initlibvirtmod_qemu(void); -+# else -+extern void initcygvirtmod_qemu(void); -+# endif - #endif - - #if 0 -@@ -343,13 +351,14 @@ static PyMethodDef libvirtQemuMethods[] - {NULL, NULL, 0, NULL} - }; - -+#if PY_MAJOR_VERSION > 2 - static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, --#ifndef __CYGWIN__ -+# ifndef __CYGWIN__ - "libvirtmod_qemu", --#else -+# else - "cygvirtmod_qemu", --#endif -+# endif - NULL, - -1, - libvirtQemuMethods, -@@ -360,11 +369,11 @@ static struct PyModuleDef moduledef = { - }; - - PyObject * --#ifndef __CYGWIN__ -+# ifndef __CYGWIN__ - PyInit_libvirtmod_qemu --#else -+# else - PyInit_cygvirtmod_qemu --#endif -+# endif - (void) - { - PyObject *module; -@@ -376,3 +385,25 @@ PyInit_cygvirtmod_qemu - - return module; - } -+#else /* ! PY_MAJOR_VERSION > 2 */ -+void -+# ifndef __CYGWIN__ -+initlibvirtmod_qemu -+# else -+initcygvirtmod_qemu -+# endif -+(void) -+{ -+ if (virInitialize() < 0) -+ return; -+ -+ /* initialize the python extension module */ -+ Py_InitModule((char *) -+# ifndef __CYGWIN__ -+ "libvirtmod_qemu", -+# else -+ "cygvirtmod_qemu", -+# endif -+ libvirtQemuMethods); -+} -+#endif /* ! PY_MAJOR_VERSION > 2 */ -Index: libvirt-python-6.0.0/libvirt-utils.c -=================================================================== ---- libvirt-python-6.0.0.orig/libvirt-utils.c -+++ libvirt-python-6.0.0/libvirt-utils.c -@@ -1,7 +1,7 @@ - /* - * libvirt-utils.c: misc helper APIs for python binding - * -- * Copyright (C) 2013-2019 Red Hat, Inc. -+ * Copyright (C) 2013 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public -@@ -274,7 +274,11 @@ setPyVirTypedParameter(PyObject *info, - int nparams) - { - PyObject *key, *value; -+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4 -+ int pos = 0; -+#else - Py_ssize_t pos = 0; -+#endif - virTypedParameterPtr temp = NULL, ret = NULL; - Py_ssize_t size; - ssize_t i; -@@ -412,6 +416,13 @@ virPyDictToTypedParamOne(virTypedParamet - type = VIR_TYPED_PARAM_LLONG; - else - type = VIR_TYPED_PARAM_ULLONG; -+#if PY_MAJOR_VERSION < 3 -+ } else if (PyInt_Check(value)) { -+ if (PyInt_AS_LONG(value) < 0) -+ type = VIR_TYPED_PARAM_LLONG; -+ else -+ type = VIR_TYPED_PARAM_ULLONG; -+#endif - } else if (PyFloat_Check(value)) { - type = VIR_TYPED_PARAM_DOUBLE; - } -@@ -509,7 +520,11 @@ virPyDictToTypedParams(PyObject *dict, - { - PyObject *key; - PyObject *value; -+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4 -+ int pos = 0; -+#else - Py_ssize_t pos = 0; -+#endif - virTypedParameterPtr params = NULL; - int n = 0; - int max = 0; -Index: libvirt-python-6.0.0/libvirt-utils.h -=================================================================== ---- libvirt-python-6.0.0.orig/libvirt-utils.h -+++ libvirt-python-6.0.0/libvirt-utils.h -@@ -139,7 +139,11 @@ int virReallocN(void *ptrptr, size_t siz - void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1); - - --# define libvirt_PyString_Check PyUnicode_Check -+# if PY_MAJOR_VERSION > 2 -+# define libvirt_PyString_Check PyUnicode_Check -+# else -+# define libvirt_PyString_Check PyString_Check -+# endif - - - #define VIR_N_ELEMENTS(array) (sizeof(array) / sizeof(*(array))) -Index: libvirt-python-6.0.0/sanitytest.py -=================================================================== ---- libvirt-python-6.0.0.orig/sanitytest.py -+++ libvirt-python-6.0.0/sanitytest.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - - import sys - import lxml -Index: libvirt-python-6.0.0/setup.py -=================================================================== ---- libvirt-python-6.0.0.orig/setup.py -+++ libvirt-python-6.0.0/setup.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python3 -+#!/usr/bin/env python - - from distutils.core import setup, Extension, Command - from distutils.command.build import build -@@ -17,10 +17,6 @@ import re - import shutil - import time - --if sys.version_info[0] != 3: -- print("libvirt-python requires Python 3.x to build") -- sys.exit(1) -- - MIN_LIBVIRT = "0.9.11" - MIN_LIBVIRT_LXC = "1.0.2" - -@@ -346,7 +342,7 @@ setup(name = 'libvirt-python', - description = 'The libvirt virtualization API python binding', - long_description = - '''The libvirt-python package provides a module that permits applications --written in the Python 3.x programming language to call the interface -+written in the Python programming language to call the interface - supplied by the libvirt library, to manage the virtualization capabilities - of recent versions of Linux (and other OSes).''', - license = 'LGPLv2+', -@@ -367,6 +363,7 @@ of recent versions of Linux (and other O - "Intended Audience :: Developers", - "License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)", - "Programming Language :: Python", -+ "Programming Language :: Python :: 2", - "Programming Language :: Python :: 3", - ] - ) -Index: libvirt-python-6.0.0/typewrappers.c -=================================================================== ---- libvirt-python-6.0.0.orig/typewrappers.c -+++ libvirt-python-6.0.0/typewrappers.c -@@ -2,88 +2,141 @@ - * types.c: converter functions between the internal representation - * and the Python objects - * -- * Copyright (C) 2005-2019 Red Hat, Inc. -+ * Copyright (C) 2005, 2007, 2012 Red Hat, Inc. - * - * Daniel Veillard - */ - - /* Horrible kludge to work around even more horrible name-space pollution -- * via Python.h. That file includes /usr/include/python3.x/pyconfig*.h, -- * which has over 180 autoconf-style HAVE_* definitions. Shame on them. */ -+ * via Python.h. That file includes /usr/include/python2.5/pyconfig*.h, -+ * which has over 180 autoconf-style HAVE_* definitions. Shame on them. */ - #undef HAVE_PTHREAD_H - - #include "typewrappers.h" - #include "libvirt-utils.h" - -+#ifndef Py_CAPSULE_H -+typedef void(*PyCapsule_Destructor)(void *, void *); -+#endif -+ - static PyObject * - libvirt_buildPyObject(void *cobj, - const char *name, - PyCapsule_Destructor destr) - { -- return PyCapsule_New(cobj, name, destr); -+ PyObject *ret; -+ -+#ifdef Py_CAPSULE_H -+ ret = PyCapsule_New(cobj, name, destr); -+#else -+ ret = PyCObject_FromVoidPtrAndDesc(cobj, (void *) name, destr); -+#endif /* _TEST_CAPSULE */ -+ -+ return ret; - } - - PyObject * - libvirt_intWrap(int val) - { -- return PyLong_FromLong((long) val); -+ PyObject *ret; -+#if PY_MAJOR_VERSION > 2 -+ ret = PyLong_FromLong((long) val); -+#else -+ ret = PyInt_FromLong((long) val); -+#endif -+ return ret; - } - - PyObject * - libvirt_uintWrap(uint val) - { -- return PyLong_FromLong((long) val); -+ PyObject *ret; -+#if PY_MAJOR_VERSION > 2 -+ ret = PyLong_FromLong((long) val); -+#else -+ ret = PyInt_FromLong((long) val); -+#endif -+ return ret; - } - - PyObject * - libvirt_longWrap(long val) - { -- return PyLong_FromLong(val); -+ PyObject *ret; -+ ret = PyLong_FromLong(val); -+ return ret; - } - - PyObject * - libvirt_ulongWrap(unsigned long val) - { -- return PyLong_FromLong(val); -+ PyObject *ret; -+ ret = PyLong_FromLong(val); -+ return ret; - } - - PyObject * - libvirt_longlongWrap(long long val) - { -- return PyLong_FromLongLong(val); -+ PyObject *ret; -+ ret = PyLong_FromLongLong(val); -+ return ret; - } - - PyObject * - libvirt_ulonglongWrap(unsigned long long val) - { -- return PyLong_FromUnsignedLongLong(val); -+ PyObject *ret; -+ ret = PyLong_FromUnsignedLongLong(val); -+ return ret; - } - - PyObject * - libvirt_charPtrSizeWrap(char *str, Py_ssize_t size) - { -+ PyObject *ret; -+ - if (str == NULL) { - return VIR_PY_NONE; - } -- return PyBytes_FromStringAndSize(str, size); -+#if PY_MAJOR_VERSION > 2 -+ ret = PyBytes_FromStringAndSize(str, size); -+#else -+ ret = PyString_FromStringAndSize(str, size); -+#endif -+ return ret; - } - - PyObject * - libvirt_charPtrWrap(char *str) - { -+ PyObject *ret; -+ - if (str == NULL) { - return VIR_PY_NONE; - } -- return PyUnicode_FromString(str); -+#if PY_MAJOR_VERSION > 2 -+ ret = PyUnicode_FromString(str); -+#else -+ ret = PyString_FromString(str); -+#endif -+ return ret; - } - - PyObject * - libvirt_constcharPtrWrap(const char *str) - { -+ PyObject *ret; -+ - if (str == NULL) { - return VIR_PY_NONE; - } -- return PyUnicode_FromString(str); -+#if PY_MAJOR_VERSION > 2 -+ ret = PyUnicode_FromString(str); -+#else -+ ret = PyString_FromString(str); -+#endif -+ return ret; - } - - PyObject * -@@ -110,7 +163,11 @@ libvirt_intUnwrap(PyObject *obj, - * to C long type directly. If it is of PyLong_Type, PyInt_AsLong - * will call PyLong_AsLong() to deal with it automatically. - */ -+#if PY_MAJOR_VERSION > 2 - long_val = PyLong_AsLong(obj); -+#else -+ long_val = PyInt_AsLong(obj); -+#endif - if ((long_val == -1) && PyErr_Occurred()) - return -1; - -@@ -139,7 +196,11 @@ libvirt_uintUnwrap(PyObject *obj, - return -1; - } - -+#if PY_MAJOR_VERSION > 2 - long_val = PyLong_AsLong(obj); -+#else -+ long_val = PyInt_AsLong(obj); -+#endif - if ((long_val == -1) && PyErr_Occurred()) - return -1; - -@@ -208,7 +269,14 @@ libvirt_longlongUnwrap(PyObject *obj, - return -1; - } - -+#if PY_MAJOR_VERSION == 2 -+ /* If obj is of PyInt_Type, PyLong_AsLongLong -+ * will call PyInt_AsLong() to handle it automatically. -+ */ -+ if (PyInt_Check(obj) || PyLong_Check(obj)) -+#else - if (PyLong_Check(obj)) -+#endif - llong_val = PyLong_AsLongLong(obj); - else - PyErr_SetString(PyExc_TypeError, "an integer is required"); -@@ -231,7 +299,21 @@ libvirt_ulonglongUnwrap(PyObject *obj, - return -1; - } - -+#if PY_MAJOR_VERSION == 2 -+ /* The PyLong_AsUnsignedLongLong doesn't check the type of -+ * obj, only accept argument of PyLong_Type, so we check it instead. -+ */ -+ if (PyInt_Check(obj)) { -+ long long llong_val = PyInt_AsLong(obj); -+ if (llong_val < 0) -+ PyErr_SetString(PyExc_OverflowError, -+ "negative Python int cannot be converted to C unsigned long long"); -+ else -+ ullong_val = llong_val; -+ } else if (PyLong_Check(obj)) { -+#else - if (PyLong_Check(obj)) { -+#endif - ullong_val = PyLong_AsUnsignedLongLong(obj); - } else { - PyErr_SetString(PyExc_TypeError, "an integer is required"); -@@ -285,7 +367,9 @@ int - libvirt_charPtrUnwrap(PyObject *obj, - char **str) - { -+#if PY_MAJOR_VERSION > 2 - PyObject *bytes; -+#endif - const char *ret; - *str = NULL; - if (!obj) { -@@ -293,15 +377,21 @@ libvirt_charPtrUnwrap(PyObject *obj, - return -1; - } - -+#if PY_MAJOR_VERSION > 2 - if (!(bytes = PyUnicode_AsUTF8String(obj))) - return -1; - ret = PyBytes_AsString(bytes); -+#else -+ ret = PyString_AsString(obj); -+#endif - if (ret) { - *str = strdup(ret); - if (!*str) - PyErr_NoMemory(); - } -+#if PY_MAJOR_VERSION > 2 - Py_DECREF(bytes); -+#endif - return ret && *str ? 0 : -1; - } - -@@ -310,6 +400,10 @@ libvirt_charPtrSizeUnwrap(PyObject *obj, - char **str, - Py_ssize_t *size) - { -+ int ret; -+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4 -+ int isize; -+#endif - *str = NULL; - *size = 0; - if (!obj) { -@@ -317,7 +411,18 @@ libvirt_charPtrSizeUnwrap(PyObject *obj, - return -1; - } - -- return PyBytes_AsStringAndSize(obj, str, size); -+#if PY_MAJOR_VERSION > 2 -+ ret = PyBytes_AsStringAndSize(obj, str, size); -+#else -+# if PY_MINOR_VERSION <= 4 -+ ret = PyString_AsStringAndSize(obj, str, &isize); -+ *size = isize; -+# else -+ ret = PyString_AsStringAndSize(obj, str, size); -+# endif -+#endif -+ -+ return ret; - } - - PyObject * -Index: libvirt-python-6.0.0/typewrappers.h -=================================================================== ---- libvirt-python-6.0.0.orig/typewrappers.h -+++ libvirt-python-6.0.0/typewrappers.h -@@ -22,6 +22,11 @@ - # define ATTRIBUTE_UNUSED - #endif - -+/* Work around really old python. */ -+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5 -+typedef ssize_t Py_ssize_t; -+#endif -+ - #if !LIBVIR_CHECK_VERSION(4, 5, 0) - typedef struct _virNWFilterBinding *virNWFilterBindingPtr; - #endif From d03d076c7dd04b3c228edf5ed5794b3d2fcd55948c321037c91ba5f559253083 Mon Sep 17 00:00:00 2001 From: James Fehlig Date: Tue, 10 Mar 2020 01:56:07 +0000 Subject: [PATCH 2/2] - Update to 6.1.0 - Add all new APIs and constants in libvirt 6.1.0 OBS-URL: https://build.opensuse.org/package/show/Virtualization/python-libvirt-python?expand=0&rev=66 --- libvirt-python-6.0.0.tar.gz | 3 --- libvirt-python-6.0.0.tar.gz.asc | 11 ----------- libvirt-python-6.1.0.tar.gz | 3 +++ libvirt-python-6.1.0.tar.gz.asc | 11 +++++++++++ python-libvirt-python.changes | 6 ++++++ python-libvirt-python.spec | 4 ++-- 6 files changed, 22 insertions(+), 16 deletions(-) delete mode 100644 libvirt-python-6.0.0.tar.gz delete mode 100644 libvirt-python-6.0.0.tar.gz.asc create mode 100644 libvirt-python-6.1.0.tar.gz create mode 100644 libvirt-python-6.1.0.tar.gz.asc diff --git a/libvirt-python-6.0.0.tar.gz b/libvirt-python-6.0.0.tar.gz deleted file mode 100644 index 1bb8303..0000000 --- a/libvirt-python-6.0.0.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:785f64755fc78a0eafecef74676fecf2bbbd2eaa6587ef697119ef6e1a68dbfd -size 196791 diff --git a/libvirt-python-6.0.0.tar.gz.asc b/libvirt-python-6.0.0.tar.gz.asc deleted file mode 100644 index d3856f7..0000000 --- a/libvirt-python-6.0.0.tar.gz.asc +++ /dev/null @@ -1,11 +0,0 @@ ------BEGIN PGP SIGNATURE----- - -iQEzBAABCAAdFiEE20ZoG7ka3OoXD6LUFViLJllr6l0FAl4fLyIACgkQFViLJllr -6l308wgApVwdA5ArrGzrT68vmX1IramfH9iEcdfbD+F+dbrxchUoqLIKP0bz2oyS -P7uyEObRtqkTmhT9O6+w9Tv5mvKJs5UdG6+phBYdHBStLoq4MxK6Tmlsw2r7cApv -Mg2jRjgKUxEkTF5J4oHT1+txhzX7lIgQ3TL6ajHsXtxoIvBdbRxZy2bth6J17S+M -gQyr14FQBj9luKZHGye4QpYQU7jclbvnaRJ96Q3zZwzALkCVTuGMRkzP2xG66dMO -6yzuh1qKzvgZecDvqi6uJ1Ylx3yrBkAZ8/1J5bxbT58LTaF+ebjrnavsAmqxejeY -TYyA1/o5I2R2sUyiVkozhBclLCNNaA== -=LgBP ------END PGP SIGNATURE----- diff --git a/libvirt-python-6.1.0.tar.gz b/libvirt-python-6.1.0.tar.gz new file mode 100644 index 0000000..44af5c1 --- /dev/null +++ b/libvirt-python-6.1.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be644f4809c0e1d368e3ac065df3c66a26dcfe61ecb607ee9706e1799f22c35a +size 196848 diff --git a/libvirt-python-6.1.0.tar.gz.asc b/libvirt-python-6.1.0.tar.gz.asc new file mode 100644 index 0000000..79b629a --- /dev/null +++ b/libvirt-python-6.1.0.tar.gz.asc @@ -0,0 +1,11 @@ +-----BEGIN PGP SIGNATURE----- + +iQEzBAABCAAdFiEE20ZoG7ka3OoXD6LUFViLJllr6l0FAl5eYUIACgkQFViLJllr +6l0TfwgAwagNNYaUxYHc9Gf4GrnifaQFrWkfsXC/zpcH0P9jWQ2T05wpyUKTwqRs +BGMCmXwgzjzYTunjhZ3scyFwGmslJmTN/TEZq4eyLJVKiydklReepngKOrR7KrxV +miqTjD2XehUCj7zltGUN+uHX0rHyP5JO/rzmPP0b9u8TimnTlQyWyM9zRfAv7UqS +er5VlAckVqQ203uRV6hzNZq2ReXxVACtvlr/vaVDF15K4gd8l9jf8risu4Y+R8V4 +kckh2LINirCNAyhVPRH5Ln2+GX0lt8VPDT7iUN+D0AZ+soFRo/D4YG4H5rgFwlzi +dsPyAvG/4qnAuWtoiPqxh7pvG+mlTA== +=CARu +-----END PGP SIGNATURE----- diff --git a/python-libvirt-python.changes b/python-libvirt-python.changes index adb3fc9..00ec9eb 100644 --- a/python-libvirt-python.changes +++ b/python-libvirt-python.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Mar 10 01:53:51 UTC 2020 - James Fehlig + +- Update to 6.1.0 + - Add all new APIs and constants in libvirt 6.1.0 + ------------------------------------------------------------------- Thu Feb 6 23:16:01 UTC 2020 - James Fehlig diff --git a/python-libvirt-python.spec b/python-libvirt-python.spec index ee6fcb6..d5efe95 100644 --- a/python-libvirt-python.spec +++ b/python-libvirt-python.spec @@ -1,7 +1,7 @@ # # spec file for package python-libvirt-python # -# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -23,7 +23,7 @@ %define srcname libvirt-python Name: python-libvirt-python URL: https://libvirt.org/ -Version: 6.0.0 +Version: 6.1.0 Release: 0 Summary: Library providing a virtualization API License: LGPL-2.1-or-later