#6 Experimental: EPEL7: Switch to Python 3
Closed 2 years ago by churchyard. Opened 3 years ago by churchyard.
rpms/ churchyard/mock epel7-py3  into  epel7

file modified
+12 -19
@@ -1,17 +1,13 @@ 

  %bcond_without tests


- %if 0%{?fedora} || 0%{?mageia} || 0%{?rhel} >= 8

+ %if 0%{?fedora} || 0%{?mageia} || 0%{?rhel} >= 7

  %global use_python3 1

  %global use_python2 0

+ %global __python %{__python3}


  %global use_python3 0

  %global use_python2 1

- %endif


- %if %{use_python3}

- %global python_sitelib %{python3_sitelib}

- %else

- %global python_sitelib %{python2_sitelib}

+ %global __python %{__python2}



  Summary: Builds packages inside chroots
@@ -52,16 +48,15 @@ 


  BuildRequires: bash-completion

  %if %{use_python3}

- Requires: python3

- Requires: python3-distro

- Requires: python3-jinja2

- Requires: python3-six >= 1.4.0

- Requires: python3-requests

- Requires: python3-rpm

- Requires: python3-pyroute2

- BuildRequires: python3-devel

+ Requires: python%{python3_pkgversion}-distro

+ Requires: python%{python3_pkgversion}-jinja2

+ Requires: python%{python3_pkgversion}-six >= 1.4.0

+ Requires: python%{python3_pkgversion}-requests

+ Requires: python%{python3_pkgversion}-rpm

+ Requires: python%{python3_pkgversion}-pyroute2

+ BuildRequires: python%{python3_pkgversion}-devel

  %if %{with tests}

- BuildRequires: python3-pylint

+ BuildRequires: python%{python3_pkgversion}-pylint



  Requires: python-ctypes
@@ -132,11 +127,9 @@ 



  %setup -q

- %if %{use_python2}

  for file in py/mock.py py/mockchain.py; do

-   sed -i 1"s|#!/usr/bin/python3 |#!/usr/bin/python |" $file

+   sed -i 1"s|#!/usr/bin/python3 |#!%{__python} |" $file


- %endif



  for i in py/mock.py py/mockchain.py; do

Since mock won't be updated on EPEL6, I guess the entire python2 part of the specfile can go away.

This is untested: I get ERROR: [Errno 1] Operation not permitted when I try to run the resulting mock in epel7 mock (even when I run it as root or as a mock-group nonroot user). But I get the same problem with python2 mock.

This is in docker:

[root@1bf4c6e0023f /]# mock --init
Traceback (most recent call last):
  File "/usr/libexec/mock/mock", line 80, in <module>
    import mockbuild.backend
  File "/usr/lib/python3.6/site-packages/mockbuild/backend.py", line 13, in <module>
    import rpm
  File "/usr/lib64/python3.6/site-packages/rpm/__init__.py", line 9, in <module>
    from rpm._rpm import *
ImportError: /usr/lib64/python3.6/site-packages/rpm/_rpm.cpython-36m-x86_64-linux-gnu.so: undefined symbol: rpmtsAddReinstallElement

Apparently, the python3-rpm package is not fully functional. I'll try to address that.

EDIT 1: Updating the rpm package fixes that.
EDIT 2: Added lower bound to the rpm dependency: 1f997f62, FEDORA-EPEL-2019-f279739dc2

Basic mock init works in docker.

fedpkg mockbuild doesn't really work, but this might be docker + selinux + whatnot kind of problem:

ERROR: Command failed: 
 # /usr/bin/systemd-nspawn -q -M dc4e71a4598744e38a77a3ff5744a7f6 -D /var/lib/mock/epel-7-x86_64/root --setenv=TERM=vt100 --setenv=SHELL=/bin/bash --setenv=HOME=/builddir --setenv=HOSTNAME=mock --setenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin --setenv=PROMPT_COMMAND=printf "\033]0;<mock-chroot>\007" --setenv=PS1=<mock-chroot> \s-\v\$  --setenv=LANG=en_US.utf-8 /usr/sbin/groupadd -g 135 mock

Could not execute mockbuild: Failed to execute command.

I guess I need a proper VM to test this.

fedpkg mockbuilding epel7 mock works with this Python 3 mock.

The patch looks good. I added back the

%global python_sitelib %{python3_sitelib}

as it is used in mockchain substitution. I have merged it in upstream and I am closing this PR.
Thank you.

mockchain substitution?

Note that defining __python to Python 3 makes %python_sitelib Python 3.

Thanks for merging.

Pull-Request has been closed by churchyard

2 years ago