[libvirt] [PATCH] build: only support python3 binary

Daniel P. Berrangé posted 1 patch 4 years, 4 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20191204101412.19753-1-berrange@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(-)
[libvirt] [PATCH] build: only support python3 binary
Posted by Daniel P. Berrangé 4 years, 4 months ago
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@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@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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] build: only support python3 binary
Posted by Michal Privoznik 4 years, 4 months ago
On 12/4/19 11:14 AM, Daniel P. Berrangé wrote:
> 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@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(-)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] build: only support python3 binary
Posted by Eric Blake 4 years, 4 months ago
On 12/4/19 4:14 AM, Daniel P. Berrangé wrote:
> 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@redhat.com>
> ---

> +++ 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])

Are there any systems with python version 3 installed only as the name 
'python', or does everyone with python 3 follow the PEP recommendations 
and have a 'python3' available?  (It matters on whether your list needs 
two instead of one spelling for acceptable programs to attempt).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] build: only support python3 binary
Posted by Daniel P. Berrangé 4 years, 4 months ago
On Wed, Dec 04, 2019 at 09:59:48AM -0600, Eric Blake wrote:
> On 12/4/19 4:14 AM, Daniel P. Berrangé wrote:
> > 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@redhat.com>
> > ---
> 
> > +++ 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])
> 
> Are there any systems with python version 3 installed only as the name
> 'python', or does everyone with python 3 follow the PEP recommendations and
> have a 'python3' available?  (It matters on whether your list needs two
> instead of one spelling for acceptable programs to attempt).

There is talk about allowing a plain 'python' to refer to python 3 as a
convenience for humans. Anywhere which does that will still also provide
a 'python3' binary. So ignoring existance of 'python' seems like the safer
option for scripts.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list