[libvirt] [PATCH] build: only support python3 binary
by Daniel P. Berrangé
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.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
configure.ac | 4 ++--
docs/apibuild.py | 4 +---
docs/reformat-news.py | 4 +---
libvirt.spec.in | 10 +---------
scripts/augeas-gentest.py | 4 +---
scripts/check-aclperms.py | 4 +---
scripts/check-aclrules.py | 4 +---
scripts/check-driverimpls.py | 4 +---
scripts/check-drivername.py | 4 +---
scripts/check-symfile.py | 4 +---
scripts/check-symsorting.py | 4 +---
scripts/dtrace2systemtap.py | 4 +---
scripts/genpolkit.py | 4 +---
scripts/gensystemtap.py | 4 +---
scripts/header-ifdef.py | 4 +---
scripts/minimize-po.py | 4 +---
scripts/mock-noinline.py | 4 +---
scripts/prohibit-duplicate-header.py | 4 +---
src/esx/esx_vi_generator.py | 4 +---
src/hyperv/hyperv_wmi_generator.py | 4 +---
tests/cputestdata/cpu-gather.sh | 9 +--------
21 files changed, 22 insertions(+), 73 deletions(-)
diff --git a/configure.ac b/configure.ac
index 76d28d2f67..2e5af075ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -701,9 +701,9 @@ if test "$with_linux" = "yes"; then
fi
dnl Allow perl/python overrides
-AC_PATH_PROGS([PYTHON], [python3 python2 python])
+AC_PATH_PROGS([PYTHON], [python3])
if test -z "$PYTHON"; then
- AC_MSG_ERROR(['python3', 'python2' or 'python' binary is required to build libvirt])
+ AC_MSG_ERROR(['python3' binary is required to build libvirt])
fi
AC_PATH_PROG([FLAKE8], [flake8])
if test -z "$FLAKE8"; then
diff --git a/docs/apibuild.py b/docs/apibuild.py
index 5a0224c1c6..2f7314b379 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# This is the API builder, it parses the C sources and build the
# API formal description in XML.
@@ -8,8 +8,6 @@
# daniel(a)veillard.com
#
-from __future__ import print_function
-
import os
import sys
import glob
diff --git a/docs/reformat-news.py b/docs/reformat-news.py
index a06f945c02..7bc752d821 100755
--- a/docs/reformat-news.py
+++ b/docs/reformat-news.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# reformat-news.py: Reformat the NEWS file properly
#
@@ -18,8 +18,6 @@
# License along with this library. If not, see
# <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-
import sys
COLUMNS = 80
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 4c6161a26f..72ed2fd96b 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -188,14 +188,6 @@
%define with_bash_completion 0%{!?_without_bash_completion:1}
-# Use Python 3 when possible, Python 2 otherwise
-%if 0%{?fedora} || 0%{?rhel} > 7
- %define python python3
-%else
- %define python python2
-%endif
-
-
%if %{with_qemu} || %{with_lxc}
# numad is used to manage the CPU and memory placement dynamically,
# it's not available on many non-x86 architectures.
@@ -281,7 +273,7 @@ BuildRequires: perl-interpreter
%else
BuildRequires: perl
%endif
-BuildRequires: %{python}
+BuildRequires: python3
BuildRequires: systemd-units
%if %{with_libxl}
BuildRequires: xen-devel
diff --git a/scripts/augeas-gentest.py b/scripts/augeas-gentest.py
index 60e12fb77e..8976785cad 100755
--- a/scripts/augeas-gentest.py
+++ b/scripts/augeas-gentest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2012-2019 Red Hat, Inc.
#
@@ -19,8 +19,6 @@
# License along with this library. If not, see
# <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-
import re
import sys
diff --git a/scripts/check-aclperms.py b/scripts/check-aclperms.py
index b1084a3758..67de0efabd 100755
--- a/scripts/check-aclperms.py
+++ b/scripts/check-aclperms.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2013-2019 Red Hat, Inc.
#
@@ -21,8 +21,6 @@
# a lot of auto-generation of code, so when these don't match
# problems occur, preventing auth from succeeding at all.
-from __future__ import print_function
-
import re
import sys
diff --git a/scripts/check-aclrules.py b/scripts/check-aclrules.py
index 5a7d275410..a1fa473174 100755
--- a/scripts/check-aclrules.py
+++ b/scripts/check-aclrules.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2013-2019 Red Hat, Inc.
#
@@ -32,8 +32,6 @@
# detected EnsureACL call recorded.
#
-from __future__ import print_function
-
import re
import sys
diff --git a/scripts/check-driverimpls.py b/scripts/check-driverimpls.py
index bc3f16a816..8289b8051e 100755
--- a/scripts/check-driverimpls.py
+++ b/scripts/check-driverimpls.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2013-2019 Red Hat, Inc.
#
@@ -17,8 +17,6 @@
# <http://www.gnu.org/licenses/>.
#
-from __future__ import print_function
-
import re
import sys
diff --git a/scripts/check-drivername.py b/scripts/check-drivername.py
index ba77a6d48d..39eff836c7 100644
--- a/scripts/check-drivername.py
+++ b/scripts/check-drivername.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2013-2019 Red Hat, Inc.
#
@@ -17,8 +17,6 @@
# <http://www.gnu.org/licenses/>.
#
-from __future__ import print_function
-
import re
import sys
diff --git a/scripts/check-symfile.py b/scripts/check-symfile.py
index 7aeb047d89..0f6e780df0 100755
--- a/scripts/check-symfile.py
+++ b/scripts/check-symfile.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2012-2019 Red Hat, Inc.
#
@@ -16,8 +16,6 @@
# License along with this library. If not, see
# <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-
import re
import subprocess
import sys
diff --git a/scripts/check-symsorting.py b/scripts/check-symsorting.py
index 8e698c0657..fd00449c44 100755
--- a/scripts/check-symsorting.py
+++ b/scripts/check-symsorting.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright (C) 2012-2019 Red Hat, Inc.
#
@@ -16,8 +16,6 @@
# License along with this library. If not, see
# <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-
import os.path
import re
import sys
diff --git a/scripts/dtrace2systemtap.py b/scripts/dtrace2systemtap.py
index d6bf1f8d1f..506db9c503 100755
--- a/scripts/dtrace2systemtap.py
+++ b/scripts/dtrace2systemtap.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2011-2019 Red Hat, Inc.
#
@@ -23,8 +23,6 @@
# python dtrace2systemtap.py probes.d > libvirt_probes.stp
#
-from __future__ import print_function
-
import re
import sys
diff --git a/scripts/genpolkit.py b/scripts/genpolkit.py
index 230d920f70..8845ea44e0 100755
--- a/scripts/genpolkit.py
+++ b/scripts/genpolkit.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2012-2019 Red Hat, Inc.
#
@@ -17,8 +17,6 @@
# <http://www.gnu.org/licenses/>.
#
-from __future__ import print_function
-
import re
import sys
diff --git a/scripts/gensystemtap.py b/scripts/gensystemtap.py
index 7b391cc911..ad808e3033 100755
--- a/scripts/gensystemtap.py
+++ b/scripts/gensystemtap.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2011-2019 Red Hat, Inc.
#
@@ -22,8 +22,6 @@
# python gensystemtap.py */*.x > libvirt_functions.stp
#
-from __future__ import print_function
-
import re
import sys
diff --git a/scripts/header-ifdef.py b/scripts/header-ifdef.py
index d5ec7b45fe..e668875f18 100644
--- a/scripts/header-ifdef.py
+++ b/scripts/header-ifdef.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2018-2019 Red Hat, Inc.
#
@@ -44,8 +44,6 @@
# ....content....
# #endif /* SYMBOL */
-from __future__ import print_function
-
import os.path
import re
import sys
diff --git a/scripts/minimize-po.py b/scripts/minimize-po.py
index d548b427e9..c305229721 100755
--- a/scripts/minimize-po.py
+++ b/scripts/minimize-po.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2018-2019 Red Hat, Inc.
#
@@ -16,8 +16,6 @@
# License along with this library. If not, see
# <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-
import re
import sys
diff --git a/scripts/mock-noinline.py b/scripts/mock-noinline.py
index b338c5f097..4fc60c0be3 100644
--- a/scripts/mock-noinline.py
+++ b/scripts/mock-noinline.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2017-2019 Red Hat, Inc.
#
@@ -16,8 +16,6 @@
# License along with this library. If not, see
# <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-
import re
import sys
diff --git a/scripts/prohibit-duplicate-header.py b/scripts/prohibit-duplicate-header.py
index 420311ccef..33a91ddbc5 100644
--- a/scripts/prohibit-duplicate-header.py
+++ b/scripts/prohibit-duplicate-header.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (C) 2016-2019 Red Hat, Inc.
#
@@ -16,8 +16,6 @@
# License along with this library. If not, see
# <http://www.gnu.org/licenses/>.
-from __future__ import print_function
-
import re
import sys
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index 2f685c0898..048f5dde9e 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# esx_vi_generator.py: generates most of the SOAP type mapping code
@@ -22,8 +22,6 @@
# <http://www.gnu.org/licenses/>.
#
-from __future__ import print_function
-
import sys
import os
import os.path
diff --git a/src/hyperv/hyperv_wmi_generator.py b/src/hyperv/hyperv_wmi_generator.py
index 3001f222f7..736eabd598 100755
--- a/src/hyperv/hyperv_wmi_generator.py
+++ b/src/hyperv/hyperv_wmi_generator.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# hyperv_wmi_generator.py: generates most of the WMI type mapping code
@@ -20,8 +20,6 @@
# <http://www.gnu.org/licenses/>.
#
-from __future__ import print_function
-
import sys
import os
import os.path
diff --git a/tests/cputestdata/cpu-gather.sh b/tests/cputestdata/cpu-gather.sh
index cefd1b0d0d..79e3fddf22 100755
--- a/tests/cputestdata/cpu-gather.sh
+++ b/tests/cputestdata/cpu-gather.sh
@@ -9,9 +9,7 @@ grep 'model name' /proc/cpuinfo | head -n1
cpuid -1r
echo
-for python in python3 python2; do
- $python <<EOF
-from __future__ import print_function
+python3 <<EOF
from struct import pack, unpack
from fcntl import ioctl
import sys, errno
@@ -51,11 +49,6 @@ except IOError as e:
pass
EOF
- if [[ $? -eq 0 ]]; then
- break
- fi
-done
-
qemu=qemu-system-x86_64
for cmd in /usr/bin/$qemu /usr/bin/qemu-kvm /usr/libexec/qemu-kvm; do
if [[ -x $cmd ]]; then
--
2.21.0
4 years, 11 months
[libvirt] [jenkins-ci PATCH] Drop support for python 2
by Daniel P. Berrangé
CentOS7 now has support for python 3 out of the box
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
guests/host_vars/libvirt-centos-7/main.yml | 2 --
guests/playbooks/update/tasks/bootstrap.yml | 6 ------
guests/vars/mappings.yml | 24 ---------------------
guests/vars/projects/base.yml | 1 -
guests/vars/projects/libvirt-python.yml | 4 ----
5 files changed, 37 deletions(-)
diff --git a/guests/host_vars/libvirt-centos-7/main.yml b/guests/host_vars/libvirt-centos-7/main.yml
index 94e29af..d730aa2 100644
--- a/guests/host_vars/libvirt-centos-7/main.yml
+++ b/guests/host_vars/libvirt-centos-7/main.yml
@@ -16,5 +16,3 @@ package_format: 'rpm'
package_manager: 'yum'
os_name: 'CentOS'
os_version: '7'
-
-ansible_python_interpreter: /usr/bin/python2
diff --git a/guests/playbooks/update/tasks/bootstrap.yml b/guests/playbooks/update/tasks/bootstrap.yml
index 2e1dc42..c77d3a1 100644
--- a/guests/playbooks/update/tasks/bootstrap.yml
+++ b/guests/playbooks/update/tasks/bootstrap.yml
@@ -7,11 +7,5 @@
- set_fact:
python: python3
-- set_fact:
- python: python2
- when:
- - os_name == 'CentOS'
- - os_version == '7'
-
- name: Bootstrap Ansible
raw: '{{ package_manager }} install -y {{ python }}'
diff --git a/guests/vars/mappings.yml b/guests/vars/mappings.yml
index 9c339f2..ce1294c 100644
--- a/guests/vars/mappings.yml
+++ b/guests/vars/mappings.yml
@@ -804,30 +804,6 @@ mappings:
CentOS7: python36-docutils
FreeBSD: py36-docutils
- python2:
- default: python
- Fedora: python2
- FreeBSD: python2
-
- python2-devel:
- deb: python-dev
- pkg: python2
- rpm: python2-devel
- cross-policy-deb: foreign
-
- python2-lxml:
- default: python-lxml
- Fedora: python2-lxml
- FreeBSD: py27-lxml
-
- python2-nose:
- default: python-nose
- Fedora: python2-nose
- FreeBSD: py27-nose
-
- python2-setuptools:
- CentOS7: python2-setuptools
-
python3:
default: python3
diff --git a/guests/vars/projects/base.yml b/guests/vars/projects/base.yml
index 275211c..29c10b4 100644
--- a/guests/vars/projects/base.yml
+++ b/guests/vars/projects/base.yml
@@ -25,7 +25,6 @@ packages:
- patch
- perl
- pkg-config
- - python2-setuptools
- python3
- python3-pip
- python3-setuptools
diff --git a/guests/vars/projects/libvirt-python.yml b/guests/vars/projects/libvirt-python.yml
index 86b5aab..71a0717 100644
--- a/guests/vars/projects/libvirt-python.yml
+++ b/guests/vars/projects/libvirt-python.yml
@@ -1,9 +1,5 @@
---
packages:
- - python2
- - python2-devel
- - python2-lxml
- - python2-nose
- python3-devel
- python3-lxml
- python3-nose
--
2.23.0
4 years, 11 months
[libvirt] [jenkins-ci PATCH] lcitool: Decouple Python interpreters for Ansible and builds
by Andrea Bolognani
We need to keep using Python 2 for Ansible, because Python 3 is
only supported by the dnf module and on CentOS 7 we have to use
the yum module instead; at the same time, all libvirt projects
have now dropped Python 2 support so we need to make sure we use
Python 3 for building them.
Decouple the Python versions used for the two purposes so that
we can keep everything working.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
guests/playbooks/update/tasks/paths.yml | 2 ++
guests/playbooks/update/templates/bashrc.j2 | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/guests/playbooks/update/tasks/paths.yml b/guests/playbooks/update/tasks/paths.yml
index aada1f3..c204462 100644
--- a/guests/playbooks/update/tasks/paths.yml
+++ b/guests/playbooks/update/tasks/paths.yml
@@ -14,6 +14,7 @@
- make
- ninja
- ninja-build
+ - python3
- su
- name: 'Look for files'
@@ -39,6 +40,7 @@
bash: '{{ commands["bash"] }}'
ccache: '{{ commands["ccache"] }}'
java: '{{ commands["java"] }}'
+ python: '{{ commands["python3"] }}'
su: '{{ commands["su"] }}'
sudoers: '{{ files["sudoers"] }}'
diff --git a/guests/playbooks/update/templates/bashrc.j2 b/guests/playbooks/update/templates/bashrc.j2
index d3fc652..9cea90c 100644
--- a/guests/playbooks/update/templates/bashrc.j2
+++ b/guests/playbooks/update/templates/bashrc.j2
@@ -2,7 +2,7 @@ export PS1="[\u@\h \w]\$ "
export MAKE="{{ make }}"
export NINJA="{{ ninja }}"
-export PYTHON="{{ ansible_python_interpreter }}"
+export PYTHON="{{ python }}"
export MAKEFLAGS="-j{{ install_vcpus|int + 1 }}"
--
2.23.0
4 years, 11 months
[libvirt] [PATCH] tests: Make check-file-access.pl accept files through argv
by Michal Privoznik
The script needs two files to open:
$(builddir)/test_file_access.txt, and
$(srcdir)/file_access_whitelist.txt.
However, the script is opening the files from the $CWD which
won't work for a VPATH build. Make the script accept paths to the
files through @ARGV and tune the Makefile.am to pass them.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tests/Makefile.am | 4 +++-
tests/check-file-access.pl | 8 ++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cbe8e86224..4c2856bf97 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -454,7 +454,9 @@ EXTRA_DIST += $(test_scripts)
if WITH_LINUX
check-access: file-access-clean
VIR_TEST_FILE_ACCESS=1 $(MAKE) $(AM_MAKEFLAGS) check
- $(PERL) check-file-access.pl | sort -u
+ $(PERL) $(abs_srcdir)/check-file-access.pl \
+ $(abs_builddir)/test_file_access.txt \
+ $(abs_srcdir)/file_access_whitelist.txt | sort -u
file-access-clean:
> test_file_access.txt
diff --git a/tests/check-file-access.pl b/tests/check-file-access.pl
index ea0b7a18a2..2926126b14 100755
--- a/tests/check-file-access.pl
+++ b/tests/check-file-access.pl
@@ -24,8 +24,12 @@
use strict;
use warnings;
-my $access_file = "test_file_access.txt";
-my $whitelist_file = "file_access_whitelist.txt";
+sub usage {
+ die "$0 access_file file_access_whitelist\n";
+}
+
+my $access_file = shift or usage();
+my $whitelist_file = shift or usage();
my @known_actions = ("open", "fopen", "access", "stat", "lstat", "connect");
--
2.23.0
4 years, 11 months
[libvirt] [PATCH v5 00/23] scripts: convert most perl scripts to python
by Daniel P. Berrangé
This series is an effort to reduce the number of different
languages we use by eliminating most use of perl in favour
of python.
This aligns with fact that the likely future build system
we'll use (meson) is written in python, and that python
is much more commonly used/understood by developers these
days than perl.
With this applied we use perl in a handful of places only:
- src/rpc/gendispatch.pl - this is a horrendously large
script and very hard to understand/follow. A straight
syntax conversion to Python would still leave a hgue
and hard to understand/follow script. It really needs
a clean room rewrite from scratch, with better structure.
- src/rpc/genprotocol.pl - fairly easy to convert, but
might be obsolete depending on approach for rewriting
gendispatch.pl, so ignored for now
- tests/oomtrace.pl - will be purge by the patches that
drop OOM handling anyway
- tools/wireshark/util/genxdrstub.pl - a very large
script, which I haven't got the courage to tackle
yet.
- cfg.mk/maint.mk - many syntax rules involve regexes
which are fed to perl. Decision on what to do
with syntax-check rules punted to another time.
- build-aux/gitlog-to-changelog
- build-aux/useless-if-before-free - Both pulled in
from gnulib. Could be rewritten quite easily if
desired, but given that we aren't maintainers of
them right now, they're ignored as they don't
really impact our developers.
Note that the check-spacing.py script is significantly
slower in Python than in Perl. After researching this
it appears there is nothing that can be done. The Perl
regex engine is simply much better optimized than the
Python one. As previously discussed we need to loook
at uncrustify or clang-format or some other tool to
validate whitespace formatting. This is ongoing. We
can either accept the slow down in the short term or
keep the Perl version in the short term.
In v5:
- Rebased to cope with changes to require VPATH build
- Merged the already-ACKd scripts
In v4:
- Moved all scripts into the scripts/ directory instead
of having them scattered around source tree
- Use re.search instead of re.match
- Don't bother re-compiling regexes
In v3:
- All scripts comply with all flake8 style rules with
exception of
E129 visually indented line with same indent as next logical line
In v2:
- Pulled in patch to hacking file
- Converted many more scripts
- Forced UTF-8 character set to avoid ascii codec
on py3 < 3.7
Daniel P. Berrangé (23):
build-aux: rewrite duplicate header checker in Python
build-aux: rewrite whitespace checker in Python
build-aux: rewrite mock inline checker in Python
build-aux: rewrite header ifdef checker in Python
src: rewrite ACL permissions checker in Python
src: rewrite symfile sorting checker in Python
src: rewrite symfile library checker in Python
src: rewrite systemtap probe generator in Python
src: rewrite systemtap function generator in Python
src: rewrite driver name checker in Python
src: rewrite driver impl checker in Python
src: rewrite ACL rule checker in Python
src: rewrite polkit ACL generator in Python
src: rewrite remote protocol checker in Python
tests: rewrite test argv line wrapper in Python
tests: rewrite qemu capability grouper in Python
tests: rewrite file access checker in Python
docs: rewrite hvsupport.html page generator in python
docs: rewrite polkit docs generator in Python
docs: move apibuild.py to the scripts/ directory
docs: move reformat-news.py to the scripts/ directory
docs: move esx_vi_generator.py to the scripts/ directory
docs: move hyperv_wmi_generator.py to the scripts/ directory
Makefile.am | 33 +-
build-aux/check-spacing.pl | 198 -------
build-aux/header-ifdef.pl | 182 -------
build-aux/mock-noinline.pl | 75 ---
build-aux/prohibit-duplicate-header.pl | 26 -
build-aux/syntax-check.mk | 32 +-
docs/Makefile.am | 16 +-
docs/genaclperms.pl | 125 -----
docs/hvsupport.pl | 459 ----------------
{docs => scripts}/apibuild.py | 0
scripts/check-aclperms.py | 75 +++
scripts/check-aclrules.py | 263 +++++++++
scripts/check-driverimpls.py | 102 ++++
scripts/check-drivername.py | 114 ++++
scripts/check-file-access.py | 123 +++++
scripts/check-remote-protocol.py | 136 +++++
scripts/check-spacing.py | 229 ++++++++
scripts/check-symfile.py | 80 +++
scripts/check-symsorting.py | 117 ++++
scripts/dtrace2systemtap.py | 143 +++++
{src/esx => scripts}/esx_vi_generator.py | 0
scripts/genaclperms.py | 123 +++++
scripts/genpolkit.py | 122 +++++
scripts/gensystemtap.py | 184 +++++++
scripts/group-qemu-caps.py | 123 +++++
scripts/header-ifdef.py | 231 ++++++++
scripts/hvsupport.py | 504 ++++++++++++++++++
.../hyperv_wmi_generator.py | 0
scripts/mock-noinline.py | 85 +++
scripts/prohibit-duplicate-header.py | 56 ++
{docs => scripts}/reformat-news.py | 0
scripts/test-wrap-argv.py | 170 ++++++
src/Makefile.am | 146 ++---
src/access/Makefile.inc.am | 6 +-
src/access/genpolkit.pl | 119 -----
src/admin/Makefile.inc.am | 6 +-
src/check-aclperms.pl | 73 ---
src/check-aclrules.pl | 252 ---------
src/check-driverimpls.pl | 80 ---
src/check-drivername.pl | 83 ---
src/check-symfile.pl | 70 ---
src/check-symsorting.pl | 106 ----
src/dtrace2systemtap.pl | 130 -----
src/esx/Makefile.inc.am | 6 +-
src/hyperv/Makefile.inc.am | 5 +-
src/rpc/Makefile.inc.am | 1 -
src/rpc/gensystemtap.pl | 193 -------
tests/Makefile.am | 3 +-
tests/check-file-access.pl | 126 -----
tests/file_access_whitelist.txt | 2 +-
tests/group-qemu-caps.pl | 124 -----
tests/test-wrap-argv.pl | 174 ------
tests/testutils.c | 16 +-
53 files changed, 3092 insertions(+), 2755 deletions(-)
delete mode 100755 build-aux/check-spacing.pl
delete mode 100644 build-aux/header-ifdef.pl
delete mode 100644 build-aux/mock-noinline.pl
delete mode 100644 build-aux/prohibit-duplicate-header.pl
delete mode 100755 docs/genaclperms.pl
delete mode 100755 docs/hvsupport.pl
rename {docs => scripts}/apibuild.py (100%)
create mode 100755 scripts/check-aclperms.py
create mode 100755 scripts/check-aclrules.py
create mode 100755 scripts/check-driverimpls.py
create mode 100644 scripts/check-drivername.py
create mode 100755 scripts/check-file-access.py
create mode 100644 scripts/check-remote-protocol.py
create mode 100755 scripts/check-spacing.py
create mode 100755 scripts/check-symfile.py
create mode 100755 scripts/check-symsorting.py
create mode 100755 scripts/dtrace2systemtap.py
rename {src/esx => scripts}/esx_vi_generator.py (100%)
create mode 100755 scripts/genaclperms.py
create mode 100755 scripts/genpolkit.py
create mode 100755 scripts/gensystemtap.py
create mode 100755 scripts/group-qemu-caps.py
create mode 100644 scripts/header-ifdef.py
create mode 100755 scripts/hvsupport.py
rename {src/hyperv => scripts}/hyperv_wmi_generator.py (100%)
create mode 100644 scripts/mock-noinline.py
create mode 100644 scripts/prohibit-duplicate-header.py
rename {docs => scripts}/reformat-news.py (100%)
create mode 100755 scripts/test-wrap-argv.py
delete mode 100755 src/access/genpolkit.pl
delete mode 100755 src/check-aclperms.pl
delete mode 100755 src/check-aclrules.pl
delete mode 100755 src/check-driverimpls.pl
delete mode 100755 src/check-drivername.pl
delete mode 100755 src/check-symfile.pl
delete mode 100755 src/check-symsorting.pl
delete mode 100755 src/dtrace2systemtap.pl
delete mode 100755 src/rpc/gensystemtap.pl
delete mode 100755 tests/check-file-access.pl
delete mode 100755 tests/group-qemu-caps.pl
delete mode 100755 tests/test-wrap-argv.pl
--
2.21.0
4 years, 11 months
[libvirt] [PATCH v2 00/15] docs: some refactoring and new docs about RPM deployment
by Daniel P. Berrangé
This refactors existing docs related to the remote driver/daemon and
URIs. It then also adds a kbase page about RPM package options.
This introduces the use of RST for docs as a replacement for HTML.
The intent is that all new docs should use RST from this point.
The POD man pages will also be converted to RST. I'll post this as
a different series.
Note this series only touches the main HTML content, not the
styling / templating using XSL. Tackling that is a separate
job I've not attempted. My guess is that we'd use either Sphinx
or Pelican to do the templating.
Existing HTML docs are candidates for conversion to RST, however,
people should *NOT* attempt todo this manually.
In this series I've converted docs/kbase/ files, using the pandoc
tool. This does a pretty good job in general but does need some
manual cleanups. First I post-processed its output to change the
heading highlighting to follow the documented style
$ cat convert.pl
my @in = <>;
my @out;
for (my $i ; $i <= $#in; $i++) {
my $line = $in[$i];
if ($line =~ /^=+$/) {
my @newout = splice @out, 0, $i - 1;
push @newout, $line;
push @newout, $out[$i-1];
push @newout, $out[$i];
push @newout, $line;
push @newout, "\n";
push @newout, ".. contents::\n";
@out = @newout;
} elsif ($line =~ /^(-|~|^|')+$/) {
$line =~ s/-/=/g;
$line =~ s/~/-/g;
$line =~ s/\^/~/g;
$line =~ s/'/^/g;
push @out, $line;
} else {
push @out, $line;
}
}
print @out;
So I'm converting with
pandoc -f html -t rst < foo.html.in | perl convert.pl > foo.rst
$EDITOR foot.rst
git rm -f foot.html.in
git add foo.rst
After pandoc & the headings convert, there's usually manual fixes
needed to deal with a few oddities pandoc gets wrong, or looks
ugly. This is still way simpler than converting the doc to rst
manually.
Changed in v2:
- Added a style guide for RST docs
- Probe for rst2html's different names
- Added make rules for building rst
- Fixed permalinks in generated docs
- Misc CSS fixes
- Auto-converted all of kbase/ directory
Daniel P. Berrangé (15):
docs: split TLS certificate setup into its own file
docs: move docs about remote driver URIs into URI docs
docs: introduce rst2html as a mandatory tool for building docs
docs: adapt filling of <head> section for rst2html output
docs: generate permalinks correctly for rst2html output
docs: relax CSS context match for pretty tables
docs: add styling for <tt> element
docs: add a minimal style guide for writing RST docs
docs: convert kbase/domainstatecapture.html.in to RST
docs: convert kbase/launch_security_sev.html.in to RST
docs: convert kbase/secureusage.html.in to RST
docs: convert kbase/locking.html.in to RST
docs: convert kbase/locking-lockd.html.in to RST
docs: convert kbase/locking-sanlock.html.in to RST
docs: add a kbase page about RPM packaging options
docs/Makefile.am | 33 +-
docs/aclpolkit.html.in | 20 +-
docs/docs.html.in | 6 +
docs/genaclperms.pl | 2 +-
docs/generic.css | 4 +-
docs/kbase.html.in | 4 +
docs/kbase/domainstatecapture.html.in | 303 -----------
docs/kbase/domainstatecapture.rst | 255 +++++++++
docs/kbase/launch_security_sev.html.in | 533 -------------------
docs/kbase/launch_security_sev.rst | 529 +++++++++++++++++++
docs/kbase/locking-lockd.html.in | 160 ------
docs/kbase/locking-lockd.rst | 121 +++++
docs/kbase/locking-sanlock.html.in | 247 ---------
docs/kbase/locking-sanlock.rst | 193 +++++++
docs/kbase/locking.html.in | 48 --
docs/kbase/locking.rst | 33 ++
docs/kbase/rpm-deployment.rst | 410 +++++++++++++++
docs/kbase/secureusage.html.in | 171 -------
docs/kbase/secureusage.rst | 131 +++++
docs/libvirt.css | 76 +--
docs/migration.html.in | 2 +-
docs/newapi.xsl | 4 +-
docs/page.xsl | 9 +-
docs/remote.html.in | 684 +------------------------
docs/styleguide.rst | 66 +++
docs/tlscerts.html.in | 413 +++++++++++++++
docs/uri.html.in | 263 ++++++++--
libvirt.spec.in | 2 +
m4/virt-external-programs.m4 | 5 +
mingw-libvirt.spec.in | 1 +
30 files changed, 2478 insertions(+), 2250 deletions(-)
delete mode 100644 docs/kbase/domainstatecapture.html.in
create mode 100644 docs/kbase/domainstatecapture.rst
delete mode 100644 docs/kbase/launch_security_sev.html.in
create mode 100644 docs/kbase/launch_security_sev.rst
delete mode 100644 docs/kbase/locking-lockd.html.in
create mode 100644 docs/kbase/locking-lockd.rst
delete mode 100644 docs/kbase/locking-sanlock.html.in
create mode 100644 docs/kbase/locking-sanlock.rst
delete mode 100644 docs/kbase/locking.html.in
create mode 100644 docs/kbase/locking.rst
create mode 100644 docs/kbase/rpm-deployment.rst
delete mode 100644 docs/kbase/secureusage.html.in
create mode 100644 docs/kbase/secureusage.rst
create mode 100644 docs/styleguide.rst
create mode 100644 docs/tlscerts.html.in
--
2.23.0
4 years, 11 months
[libvirt] [PATCH] tests: stop static linking to libvirt code in tests
by Daniel P. Berrangé
If we static link to libvirt_util.la then we can't override functions in
this file by simply implementing them in the test code. Any tests should
dynamic link to the main libvirt.la and ensure symbols are exported.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/libvirt_private.syms | 2 ++
tests/Makefile.am | 11 +++--------
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8fe0bf9365..0864de030b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -915,6 +915,8 @@ virDomainSnapshotDefFormat;
virDomainSnapshotDefIsExternal;
virDomainSnapshotDefNew;
virDomainSnapshotDefParseString;
+virDomainSnapshotDiskDefFree;
+virDomainSnapshotDiskDefParseXML;
virDomainSnapshotFormatConvertXMLFlags;
virDomainSnapshotIsExternal;
virDomainSnapshotLocationTypeFromString;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e009de830c..af8fd69842 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -662,8 +662,7 @@ qemublocktest_SOURCES = \
$(NULL)
qemublocktest_LDADD = \
libqemumonitortestutils.la \
- ../src/libvirt_conf.la \
- ../src/libvirt_util.la \
+ ../src/libvirt.la \
$(qemu_LDADDS) \
$(NULL)
@@ -939,8 +938,7 @@ storagevolxml2argvtest_SOURCES = \
storagevolxml2argvtest_LDADD = \
$(LIBXML_LIBS) \
../src/libvirt_driver_storage_impl.la \
- ../src/libvirt_conf.la \
- ../src/libvirt_util.la \
+ ../src/libvirt.la \
$(LDADDS)
storagepoolxml2argvtest_SOURCES = \
@@ -949,8 +947,7 @@ storagepoolxml2argvtest_SOURCES = \
storagepoolxml2argvtest_LDADD = \
$(LIBXML_LIBS) \
../src/libvirt_driver_storage_impl.la \
- ../src/libvirt_conf.la \
- ../src/libvirt_util.la \
+ ../src/libvirt.la \
$(LDADDS)
storagepoolxml2xmltest_SOURCES = \
@@ -1150,8 +1147,6 @@ virstoragetest_SOURCES = \
virstoragetest.c testutils.h testutils.c
virstoragetest_LDADD = $(LDADDS) \
../src/libvirt.la \
- ../src/libvirt_conf.la \
- ../src/libvirt_util.la \
../src/libvirt_driver_storage_impl.la \
../gnulib/lib/libgnu.la \
$(NULL)
--
2.23.0
4 years, 11 months
[libvirt] [PATCH] scripts: fix list indexing when printing mis-ordered symbols
by Daniel P. Berrangé
The python array slice syntax expects the first and last indexes,
not the first length and element count.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
scripts/check-symsorting.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/check-symsorting.py b/scripts/check-symsorting.py
index 8e698c0657..006c42f1b3 100755
--- a/scripts/check-symsorting.py
+++ b/scripts/check-symsorting.py
@@ -59,8 +59,8 @@ def check_sorting(group, symfile, line, groupfile, lastgroup):
issorted = False
if not issorted:
- actual = group[first:(last - first + 1)]
- expect = sortedgroup[first:(last - first + 1)]
+ actual = group[first:last]
+ expect = sortedgroup[first:last]
print("Symbol block at %s:%s: symbols not sorted" %
(symfile, line), file=sys.stderr)
for g in actual:
--
2.23.0
4 years, 11 months
[libvirt] [python PATCH] Drop support for python 2
by Daniel P. Berrangé
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
examples/consolecallback.py | 2 +-
examples/dhcpleases.py | 2 +-
examples/dominfo.py | 2 +-
examples/domipaddrs.py | 2 +-
examples/domrestore.py | 2 +-
examples/domsave.py | 2 +-
examples/domstart.py | 2 +-
examples/esxlist.py | 2 +-
examples/event-test.py | 2 +-
examples/guest-vcpus/guest-vcpu-daemon.py | 2 +-
examples/guest-vcpus/guest-vcpu.py | 2 +-
examples/nodestats.py | 2 +-
examples/sparsestream.py | 2 +-
examples/topology.py | 2 +-
generator.py | 2 +-
libvirt-lxc-override.c | 51 ++-------
libvirt-override.c | 51 ++-------
libvirt-python.spec.in | 96 +---------------
libvirt-qemu-override.c | 51 ++-------
libvirt-utils.c | 17 +--
libvirt-utils.h | 6 +-
sanitytest.py | 2 +-
setup.py | 9 +-
typewrappers.c | 133 +++-------------------
typewrappers.h | 5 -
25 files changed, 71 insertions(+), 380 deletions(-)
diff --git a/examples/consolecallback.py b/examples/consolecallback.py
index c539a92..1347384 100644
--- a/examples/consolecallback.py
+++ b/examples/consolecallback.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# consolecallback - provide a persistent console that survives guest reboots
import sys, os, logging, libvirt, tty, termios, atexit
diff --git a/examples/dhcpleases.py b/examples/dhcpleases.py
index da51f52..f394541 100755
--- a/examples/dhcpleases.py
+++ b/examples/dhcpleases.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# netdhcpleases - print leases info for given virtual network
import libvirt
diff --git a/examples/dominfo.py b/examples/dominfo.py
index d3049cd..0a39f4c 100755
--- a/examples/dominfo.py
+++ b/examples/dominfo.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# dominfo - print some information about a domain
import libvirt
diff --git a/examples/domipaddrs.py b/examples/domipaddrs.py
index d6d5cac..bda308c 100755
--- a/examples/domipaddrs.py
+++ b/examples/domipaddrs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# domipaddrs - print domain interfaces along with their MAC and IP addresses
import libvirt
diff --git a/examples/domrestore.py b/examples/domrestore.py
index 06fdfbc..96f4955 100755
--- a/examples/domrestore.py
+++ b/examples/domrestore.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# domstart - make sure a given domU is running, if not start it
import libvirt
diff --git a/examples/domsave.py b/examples/domsave.py
index 727217c..4940cce 100755
--- a/examples/domsave.py
+++ b/examples/domsave.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# domstart - make sure a given domU is running, if not start it
import libvirt
diff --git a/examples/domstart.py b/examples/domstart.py
index ce1b60c..7ff6cb9 100755
--- a/examples/domstart.py
+++ b/examples/domstart.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# domstart - make sure a given domU is running, if not start it
import libvirt
diff --git a/examples/esxlist.py b/examples/esxlist.py
index 0d47b00..d86e064 100755
--- a/examples/esxlist.py
+++ b/examples/esxlist.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# esxlist - list active domains of an ESX host and print some info.
# also demonstrates how to use the libvirt.openAuth() method
diff --git a/examples/event-test.py b/examples/event-test.py
index 4458e22..fddef64 100755
--- a/examples/event-test.py
+++ b/examples/event-test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
#
#
diff --git a/examples/guest-vcpus/guest-vcpu-daemon.py b/examples/guest-vcpus/guest-vcpu-daemon.py
index c7c08a8..30fcb9c 100755
--- a/examples/guest-vcpus/guest-vcpu-daemon.py
+++ b/examples/guest-vcpus/guest-vcpu-daemon.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import libvirt
import threading
diff --git a/examples/guest-vcpus/guest-vcpu.py b/examples/guest-vcpus/guest-vcpu.py
index 8faba87..479ec40 100755
--- a/examples/guest-vcpus/guest-vcpu.py
+++ b/examples/guest-vcpus/guest-vcpu.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import libvirt
import sys
diff --git a/examples/nodestats.py b/examples/nodestats.py
index c01dead..ae2a442 100755
--- a/examples/nodestats.py
+++ b/examples/nodestats.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Print some host NUMA node statistics
#
# Authors:
diff --git a/examples/sparsestream.py b/examples/sparsestream.py
index e960c40..d7c09b7 100755
--- a/examples/sparsestream.py
+++ b/examples/sparsestream.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Example of sparse streams usage
#
# Authors:
diff --git a/examples/topology.py b/examples/topology.py
index 191669c..197c87a 100755
--- a/examples/topology.py
+++ b/examples/topology.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Parse topology information from the capabilities XML and use
# them to calculate host topology
#
diff --git a/generator.py b/generator.py
index 3352521..cba9d47 100755
--- a/generator.py
+++ b/generator.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# generate python wrappers from the XML API description
#
diff --git a/libvirt-lxc-override.c b/libvirt-lxc-override.c
index d7af154..138ba5b 100644
--- a/libvirt-lxc-override.c
+++ b/libvirt-lxc-override.c
@@ -4,13 +4,13 @@
* entry points where an automatically generated stub is
* unpractical
*
- * Copyright (C) 2012-2013 Red Hat, Inc.
+ * Copyright (C) 2012-2019 Red Hat, Inc.
*
* Daniel Veillard <veillard(a)redhat.com>
*/
/* Horrible kludge to work around even more horrible name-space pollution
- via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
+ via Python.h. That file includes /usr/include/python3.x/pyconfig*.h,
which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
#undef HAVE_PTHREAD_H
@@ -21,18 +21,10 @@
#include "libvirt-utils.h"
#include "build/libvirt-lxc.h"
-#if PY_MAJOR_VERSION > 2
-# ifndef __CYGWIN__
+#ifndef __CYGWIN__
extern PyObject *PyInit_libvirtmod_lxc(void);
-# else
-extern PyObject *PyInit_cygvirtmod_lxc(void);
-# endif
#else
-# ifndef __CYGWIN__
-extern void initlibvirtmod_lxc(void);
-# else
-extern void initcygvirtmod_lxc(void);
-# endif
+extern PyObject *PyInit_cygvirtmod_lxc(void);
#endif
#if 0
@@ -107,14 +99,13 @@ 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,
@@ -125,11 +116,11 @@ static struct PyModuleDef moduledef = {
};
PyObject *
-# ifndef __CYGWIN__
+#ifndef __CYGWIN__
PyInit_libvirtmod_lxc
-# else
+#else
PyInit_cygvirtmod_lxc
-# endif
+#endif
(void)
{
PyObject *module;
@@ -141,25 +132,3 @@ 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 */
diff --git a/libvirt-override.c b/libvirt-override.c
index 2e24d27..4e4c00a 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -4,13 +4,13 @@
* entry points where an automatically generated stub is
* unpractical
*
- * Copyright (C) 2005, 2007-2015 Red Hat, Inc.
+ * Copyright (C) 2005-2019 Red Hat, Inc.
*
* Daniel Veillard <veillard(a)redhat.com>
*/
/* Horrible kludge to work around even more horrible name-space pollution
- via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
+ via Python.h. That file includes /usr/include/python3.x/pyconfig*.h,
which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
#undef HAVE_PTHREAD_H
@@ -25,18 +25,10 @@
#include "build/libvirt.h"
#include "libvirt-utils.h"
-#if PY_MAJOR_VERSION > 2
-# ifndef __CYGWIN__
+#ifndef __CYGWIN__
extern PyObject *PyInit_libvirtmod(void);
-# else
-extern PyObject *PyInit_cygvirtmod(void);
-# endif
#else
-# ifndef __CYGWIN__
-extern void initlibvirtmod(void);
-# else
-extern void initcygvirtmod(void);
-# endif
+extern PyObject *PyInit_cygvirtmod(void);
#endif
#if 0
@@ -10553,14 +10545,13 @@ 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,
@@ -10571,11 +10562,11 @@ static struct PyModuleDef moduledef = {
};
PyObject *
-# ifndef __CYGWIN__
+#ifndef __CYGWIN__
PyInit_libvirtmod
-# else
+#else
PyInit_cygvirtmod
-# endif
+#endif
(void)
{
PyObject *module;
@@ -10587,25 +10578,3 @@ 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 */
diff --git a/libvirt-python.spec.in b/libvirt-python.spec.in
index 8506840..1e92f3c 100644
--- a/libvirt-python.spec.in
+++ b/libvirt-python.spec.in
@@ -12,26 +12,7 @@
%define supported_platform 0
%endif
-%define _with_python2 1
-%if 0%{?fedora} > 30 || 0%{?rhel} > 7
-%define _with_python2 0
-%endif
-
-%define _with_python3 0
-%if 0%{?fedora} || 0%{?rhel} > 7
-%define _with_python3 1
-%endif
-
-# Whether py2 packages are assumed to have python2- name prefix
-%define py2_versioned_deps 0
-%if 0%{?fedora} || 0%{?rhel} > 7
-%define py2_versioned_deps 1
-%endif
-
-%{!?with_python2: %define with_python2 %{_with_python2}}
-%{!?with_python3: %define with_python3 %{_with_python3}}
-
-Summary: The libvirt virtualization API python2 binding
+Summary: The libvirt virtualization API python3 binding
Name: libvirt-python
Version: @PY_VERSION@
Release: 1%{?dist}
@@ -39,31 +20,13 @@ Source0: http://libvirt.org/sources/python/%{name}-%{version}.tar.gz
Url: http://libvirt.org
License: LGPLv2+
BuildRequires: libvirt-devel == %{version}
-%if %{with_python2}
-%if %{py2_versioned_deps}
-BuildRequires: python2-devel
-BuildRequires: python2-nose
-BuildRequires: python2-lxml
-%else
-BuildRequires: python-devel
-BuildRequires: python-nose
-BuildRequires: python-lxml
-%endif
-%endif
-%if %{with_python3}
BuildRequires: python3-devel
BuildRequires: python3-nose
BuildRequires: python3-lxml
-%endif
BuildRequires: gcc
# Don't want provides for python shared objects
-%if %{with_python2}
-%{?filter_provides_in: %filter_provides_in %{python2_sitearch}/.*\.so}
-%endif
-%if %{with_python3}
%{?filter_provides_in: %filter_provides_in %{python3_sitearch}/.*\.so}
-%endif
%{?filter_setup}
%description
@@ -72,23 +35,6 @@ written in the Python programming language to use the interface
supplied by the libvirt library to use the virtualization capabilities
of recent versions of Linux (and other OSes).
-%if %{with_python2}
-%package -n python2-libvirt
-Summary: The libvirt virtualization API python2 binding
-Url: http://libvirt.org
-License: LGPLv2+
-%{?python_provide:%python_provide python2-libvirt}
-Provides: libvirt-python = %{version}-%{release}
-Obsoletes: libvirt-python <= 3.6.0-1%{?dist}
-
-%description -n python2-libvirt
-The python2-libvirt package contains a module that permits applications
-written in the Python programming language to use the interface
-supplied by the libvirt library to use the virtualization capabilities
-of recent versions of Linux (and other OSes).
-%endif
-
-%if %{with_python3}
%package -n python3-libvirt
Summary: The libvirt virtualization API python3 binding
Url: http://libvirt.org
@@ -99,16 +45,15 @@ Obsoletes: libvirt-python3 <= 3.6.0-1%{?dist}
%description -n python3-libvirt
The python3-libvirt package contains a module that permits applications
-written in the Python programming language to use the interface
+written in the Python 3.x programming language to use the interface
supplied by the libvirt library to use the virtualization capabilities
of recent versions of Linux (and other OSes).
-%endif
%prep
%setup -q
# Unset execute bit for example scripts; it can introduce spurious
-# RPM dependencies, like /usr/bin/python which can pull in python2
+# RPM dependencies, like /usr/bin/python3
# for the -python3 package
find examples -type f -exec chmod 0644 \{\} \;
@@ -118,56 +63,22 @@ echo "This RPM requires either Fedora >= %{min_fedora} or RHEL >= %{min_rhel}"
exit 1
%endif
-%if %{with_python2}
-%if 0%{?fedora} || 0%{?rhel} >= 8
-%py2_build
-%else
-CFLAGS="$RPM_OPT_FLAGS" %{__python2} setup.py build
-%endif
-%endif
-%if %{with_python3}
%if 0%{?fedora} || 0%{?rhel} >= 8
%py3_build
%else
CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build
%endif
-%endif
%install
-%if %{with_python2}
-%if 0%{?fedora} || 0%{?rhel} >= 8
-%py2_install
-%else
-%{__python2} setup.py install --skip-build --root=%{buildroot}
-%endif
-%endif
-%if %{with_python3}
%if 0%{?fedora} || 0%{?rhel} >= 8
%py3_install
%else
%{__python3} setup.py install --skip-build --root=%{buildroot}
%endif
-%endif
%check
-%if %{with_python2}
-%{__python2} setup.py test
-%endif
-%if %{with_python3}
%{__python3} setup.py test
-%endif
-%if %{with_python2}
-%files -n python2-libvirt
-%doc ChangeLog AUTHORS NEWS README COPYING COPYING.LESSER examples/
-%{python2_sitearch}/libvirt.py*
-%{python2_sitearch}/libvirt_qemu.py*
-%{python2_sitearch}/libvirt_lxc.py*
-%{python2_sitearch}/libvirtmod*
-%{python2_sitearch}/*egg-info
-%endif
-
-%if %{with_python3}
%files -n python3-libvirt
%doc ChangeLog AUTHORS NEWS README COPYING COPYING.LESSER examples/
%{python3_sitearch}/libvirt.py*
@@ -180,6 +91,5 @@ CFLAGS="$RPM_OPT_FLAGS" %{__python3} setup.py build
%{python3_sitearch}/__pycache__/libvirtaio.cpython-*.py*
%{python3_sitearch}/libvirtmod*
%{python3_sitearch}/*egg-info
-%endif
%changelog
diff --git a/libvirt-qemu-override.c b/libvirt-qemu-override.c
index f166f6e..6ae95b4 100644
--- a/libvirt-qemu-override.c
+++ b/libvirt-qemu-override.c
@@ -4,13 +4,13 @@
* entry points where an automatically generated stub is
* unpractical
*
- * Copyright (C) 2011-2014 Red Hat, Inc.
+ * Copyright (C) 2011-2019 Red Hat, Inc.
*
* Daniel Veillard <veillard(a)redhat.com>
*/
/* Horrible kludge to work around even more horrible name-space pollution
- via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
+ via Python.h. That file includes /usr/include/python3.x/pyconfig*.h,
which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
#undef HAVE_PTHREAD_H
@@ -21,18 +21,10 @@
#include "libvirt-utils.h"
#include "build/libvirt-qemu.h"
-#if PY_MAJOR_VERSION > 2
-# ifndef __CYGWIN__
+#ifndef __CYGWIN__
extern PyObject *PyInit_libvirtmod_qemu(void);
-# else
-extern PyObject *PyInit_cygvirtmod_qemu(void);
-# endif
#else
-# ifndef __CYGWIN__
-extern void initlibvirtmod_qemu(void);
-# else
-extern void initcygvirtmod_qemu(void);
-# endif
+extern PyObject *PyInit_cygvirtmod_qemu(void);
#endif
#if 0
@@ -351,14 +343,13 @@ 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,
@@ -369,11 +360,11 @@ static struct PyModuleDef moduledef = {
};
PyObject *
-# ifndef __CYGWIN__
+#ifndef __CYGWIN__
PyInit_libvirtmod_qemu
-# else
+#else
PyInit_cygvirtmod_qemu
-# endif
+#endif
(void)
{
PyObject *module;
@@ -385,25 +376,3 @@ 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 */
diff --git a/libvirt-utils.c b/libvirt-utils.c
index 78b94ca..d8ff11d 100644
--- a/libvirt-utils.c
+++ b/libvirt-utils.c
@@ -1,7 +1,7 @@
/*
* libvirt-utils.c: misc helper APIs for python binding
*
- * Copyright (C) 2013 Red Hat, Inc.
+ * Copyright (C) 2013-2019 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,11 +274,7 @@ 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;
@@ -416,13 +412,6 @@ virPyDictToTypedParamOne(virTypedParameterPtr *params,
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;
}
@@ -520,11 +509,7 @@ 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;
diff --git a/libvirt-utils.h b/libvirt-utils.h
index cc3d278..82f0af8 100644
--- a/libvirt-utils.h
+++ b/libvirt-utils.h
@@ -139,11 +139,7 @@ int virReallocN(void *ptrptr, size_t size, size_t count)
void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1);
-# if PY_MAJOR_VERSION > 2
-# define libvirt_PyString_Check PyUnicode_Check
-# else
-# define libvirt_PyString_Check PyString_Check
-# endif
+# define libvirt_PyString_Check PyUnicode_Check
#define VIR_N_ELEMENTS(array) (sizeof(array) / sizeof(*(array)))
diff --git a/sanitytest.py b/sanitytest.py
index 0b415fd..1bedd55 100644
--- a/sanitytest.py
+++ b/sanitytest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import sys
import lxml
diff --git a/setup.py b/setup.py
index 117f6ff..ea25dc0 100755
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
from distutils.core import setup, Extension, Command
from distutils.command.build import build
@@ -17,6 +17,10 @@ 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"
@@ -341,7 +345,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 programming language to call the interface
+written in the Python 3.x 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+',
@@ -362,7 +366,6 @@ of recent versions of Linux (and other OSes).''',
"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",
]
)
diff --git a/typewrappers.c b/typewrappers.c
index 2507859..3b1df87 100644
--- a/typewrappers.c
+++ b/typewrappers.c
@@ -2,141 +2,88 @@
* types.c: converter functions between the internal representation
* and the Python objects
*
- * Copyright (C) 2005, 2007, 2012 Red Hat, Inc.
+ * Copyright (C) 2005-2019 Red Hat, Inc.
*
* Daniel Veillard <veillard(a)redhat.com>
*/
/* Horrible kludge to work around even more horrible name-space pollution
- * via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
- * which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
+ * via Python.h. That file includes /usr/include/python3.x/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)
{
- 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;
+ return PyCapsule_New(cobj, name, destr);
}
PyObject *
libvirt_intWrap(int val)
{
- PyObject *ret;
-#if PY_MAJOR_VERSION > 2
- ret = PyLong_FromLong((long) val);
-#else
- ret = PyInt_FromLong((long) val);
-#endif
- return ret;
+ return PyLong_FromLong((long) val);
}
PyObject *
libvirt_uintWrap(uint val)
{
- PyObject *ret;
-#if PY_MAJOR_VERSION > 2
- ret = PyLong_FromLong((long) val);
-#else
- ret = PyInt_FromLong((long) val);
-#endif
- return ret;
+ return PyLong_FromLong((long) val);
}
PyObject *
libvirt_longWrap(long val)
{
- PyObject *ret;
- ret = PyLong_FromLong(val);
- return ret;
+ return PyLong_FromLong(val);
}
PyObject *
libvirt_ulongWrap(unsigned long val)
{
- PyObject *ret;
- ret = PyLong_FromLong(val);
- return ret;
+ return PyLong_FromLong(val);
}
PyObject *
libvirt_longlongWrap(long long val)
{
- PyObject *ret;
- ret = PyLong_FromLongLong(val);
- return ret;
+ return PyLong_FromLongLong(val);
}
PyObject *
libvirt_ulonglongWrap(unsigned long long val)
{
- PyObject *ret;
- ret = PyLong_FromUnsignedLongLong(val);
- return ret;
+ return PyLong_FromUnsignedLongLong(val);
}
PyObject *
libvirt_charPtrSizeWrap(char *str, Py_ssize_t size)
{
- PyObject *ret;
-
if (str == NULL) {
return VIR_PY_NONE;
}
-#if PY_MAJOR_VERSION > 2
- ret = PyBytes_FromStringAndSize(str, size);
-#else
- ret = PyString_FromStringAndSize(str, size);
-#endif
- return ret;
+ return PyBytes_FromStringAndSize(str, size);
}
PyObject *
libvirt_charPtrWrap(char *str)
{
- PyObject *ret;
-
if (str == NULL) {
return VIR_PY_NONE;
}
-#if PY_MAJOR_VERSION > 2
- ret = PyUnicode_FromString(str);
-#else
- ret = PyString_FromString(str);
-#endif
- return ret;
+ return PyUnicode_FromString(str);
}
PyObject *
libvirt_constcharPtrWrap(const char *str)
{
- PyObject *ret;
-
if (str == NULL) {
return VIR_PY_NONE;
}
-#if PY_MAJOR_VERSION > 2
- ret = PyUnicode_FromString(str);
-#else
- ret = PyString_FromString(str);
-#endif
- return ret;
+ return PyUnicode_FromString(str);
}
PyObject *
@@ -163,11 +110,7 @@ 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;
@@ -196,11 +139,7 @@ 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;
@@ -269,14 +208,7 @@ 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");
@@ -299,21 +231,7 @@ 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");
@@ -367,9 +285,7 @@ int
libvirt_charPtrUnwrap(PyObject *obj,
char **str)
{
-#if PY_MAJOR_VERSION > 2
PyObject *bytes;
-#endif
const char *ret;
*str = NULL;
if (!obj) {
@@ -377,21 +293,15 @@ 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;
}
@@ -400,10 +310,6 @@ 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) {
@@ -411,18 +317,7 @@ libvirt_charPtrSizeUnwrap(PyObject *obj,
return -1;
}
-#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;
+ return PyBytes_AsStringAndSize(obj, str, size);
}
PyObject *
diff --git a/typewrappers.h b/typewrappers.h
index 486017a..fc923bf 100644
--- a/typewrappers.h
+++ b/typewrappers.h
@@ -22,11 +22,6 @@
# 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
--
2.21.0
4 years, 11 months