[libvirt] [jenkins-ci PATCH] Drop support for python 2

Daniel P. Berrangé posted 1 patch 4 years, 4 months ago
Failed in applying to current master (apply log)
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(-)
[libvirt] [jenkins-ci PATCH] Drop support for python 2
Posted by Daniel P. Berrangé 4 years, 4 months ago
CentOS7 now has support for python 3 out of the box

Signed-off-by: Daniel P. Berrangé <berrange@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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [jenkins-ci PATCH] Drop support for python 2
Posted by Andrea Bolognani 4 years, 4 months ago
On Wed, 2019-12-04 at 13:26 +0000, Daniel P. Berrangé wrote:
[...]
> +++ 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

This will not work: you need to explicitly point Ansible to a Python
3 interpreter, or it will still prefer Python 2 if available, which
it still is on CentOS 7.

Actually, it's more complicated than that: if you point Ansible to a
Python 3 interpreter, you will soon get

  TASK [Enable EPEL repository] *************************************
  fatal: [libvirt-centos-7]: FAILED! => {"changed": false, "msg":
  "The Python 2 bindings for rpm are needed for this module. If you
  require Python 3 support use the `dnf` Ansible module instead.. The
  Python 2 yum module is needed for this module. If you require
  Python 3 support use the `dnf` Ansible module instead."}

I have posted

  https://www.redhat.com/archives/libvir-list/2019-December/msg00239.html

which addresses the issue. Please drop this hunk.

[...]
> +++ 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'

We don't want this, because as mentioned above we still need Python 2
for Ansible. Please drop this hunk.

[...]
> +++ 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

These other changes are fine, so

  Reviewed-by: Andrea Bolognani <abologna@redhat.com>

if you drop the first two hunks and push after the patch of mine
I mentioned above.

Note that the libvirt-python-rpm job will still fail with

  $ rpmbuild --clean --define "_topdir `pwd`/rpmbuild" -ta dist/*.tar.gz
  error: Failed build dependencies:
    python3-nose is needed by libvirt-python-5.10.0-1.el7.x86_64

That's because on CentOS 7 we have python36-nose (from EPEL) instead
of python3-nose, and python36-lxml instead of python3-lxml. These
issues need to be fixed in libvirt-python, though.

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [jenkins-ci PATCH] Drop support for python 2
Posted by Fabiano Fidêncio 4 years, 4 months ago
Daniel,

[snip]

> 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

We cannot do that, unfortunately.

I've tried, in the past, but "yum" ansible module requires python2.

[snip]

Best Regards,
-- 
Fabiano Fidêncio


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