#54 Set %__python3 to /usr/bin/python3.6 by default
Merged 2 years ago by churchyard. Opened 2 years ago by gotmax23.
rpms/ gotmax23/epel-rpm-macros python3.6  into  epel8

@@ -1,5 +1,3 @@ 

- addFilter("epel-rpm-macros\.src: W: strange-permission cmake-(build|configure|install) 755")

- addFilter("epel-rpm-macros\.src: W: strange-permission gpgverify 755")

  addFilter("no-%build-section")

  addFilter("no-documentation")

  addFilter("only-non-binary-in-usr-lib")

file modified
+4 -1
@@ -1,6 +1,6 @@ 

  Name:           epel-rpm-macros

  Version:        8

- Release:        33

+ Release:        34

  Summary:        Extra Packages for Enterprise Linux RPM macros

  

  License:        GPLv2
@@ -112,6 +112,9 @@ 

  

  

  %changelog

+ * Tue Nov 08 2022 Maxwell G <gotmax@e.email> - 8-34

+ - Set %%__python3 to /usr/bin/python3.6 by default

+ 

  * Wed Aug 24 2022 Iñaki Úcar <iucar@fedoraproject.org> - 8-33

  - Backport java_arches macro from Fedora

  

file modified
+17 -1
@@ -9,7 +9,23 @@ 

  # and the default is /usr/libexec/platform-python.

  # Usually, we don't want EPEL packages to use platform-python.

  # Packages that want to do that can explicitly override this.

- %__python3 /usr/bin/python%{_python3_pkgversion_with_dot}

+ #

+ # When %%python3_pkgveresion is set to 3 (i.e. the default), we override

+ # %%__python3 to /usr/bin/python3.6 to ensure that programs are always run with

+ # python3.6, even if /usr/bin/python3 is a symlink to a different interpreter.

+ #

+ # See https://lists.fedoraproject.org/archives/list/epel-devel@lists.fedoraproject.org/thread/RE3PG72B5AX7NTACPDSBGOWCMN7I3OQJ/

+ 

+ %__python3 %{lua:

+ local bin = "/usr/bin/python"

+ if rpm.expand("%python3_pkgversion") == "3" then

+         bin = bin .. "3.6"

+ else

+         bin = bin .. rpm.expand("%{_python3_pkgversion_with_dot}")

+ end

+ print(bin)

+ }

+ 

  

  # RHEL 8's %%pytest does not work properly on non-default Python versions.

  # Backported from https://src.fedoraproject.org/rpms/python-rpm-macros/c/02536540768555dde6d675935db45df81bcab7bf?branch=rawhide

When %%python3_pkgveresion is set to 3 (i.e. the default), we override
%%__python3 to /usr/bin/python3.6 to ensure that programs are always run
with python3.6, even if /usr/bin/python3 is a symlink to a different
interpreter.

After:

$ rpm -E %python3
/usr/bin/python3.6
$ rpm -E %__python3
/usr/bin/python3.6
$ rpm -D 'python3_pkgversion 3.6' -E %__python3
/usr/bin/python3.6
$ rpm -D 'python3_pkgversion 3.8' -E %__python3
/usr/bin/python3.8
$ rpm -D 'python3_pkgversion 3.9' -E %__python3
/usr/bin/python3.9
$ rpm -D 'python3_pkgversion 3.11' -E %__python3
/usr/bin/python3.11
$ rpm -D 'python3_pkgversion 3.11' -E %python3
/usr/bin/python3.11
$ rpm -D 'python3_pkgversion 3.6' -E %python3
/usr/bin/python3.6
$ rpm -E %python3
/usr/bin/python3.6

Before:

$ rpm -E %python3
/usr/bin/python3
$ rpm -D 'python3_pkgversion 3.8' -E %python3
/usr/bin/python3.8
[...]

Relates: https://lists.fedoraproject.org/archives/list/epel-devel@lists.fedoraproject.org/thread/RE3PG72B5AX7NTACPDSBGOWCMN7I3OQJ/

CC: @churchyard

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

I forgot to escape macros in the changelog again :(. I wish rpmdev-bumpspec -c would escape macros automatically.

rebased onto ba3cef5

2 years ago

1 new commit added

  • Fix rpmlint errors
2 years ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

I am afraid the installability test does not work with EPEL :(

I am afraid the installability test does not work with EPEL :(

Indeed, it does not. I was going to file an issue, but then I saw that they're phasing this out anyways: https://pagure.io/fedora-ci/general/issue/369.

EDIT: It doesn't work for EPEL 8, but I think it works for EPEL 9. But don't quote me on that :).

@lzachar Could you please help me test this? The idea is that your package that had problems could be built with this (no hacks in spec needed) and if the user has /usr/bin/python3 pointing to Python 3.9, your package would still use 3.6. The code looks OK to me, so all we need is a verification. I could do it, but I figured since you had the issue, you might as well do it as well.

I can reproduce the issue:

(Note that ansible-core is built for python3.9 and yamllint is built for python3.6)

$ podman run --rm -ti almalinux:8
# dnf install -y ansible-core
# dnf install -y epel-release
# dnf install -y yamllint
# yamllint
Traceback (most recent call last):
  File "/usr/bin/yamllint", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3239, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3222, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3251, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 567, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 884, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 770, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'yamllint==1.28.0' distribution was not found and is required by the application

Any package that contains exectuable(s) with /usr/bin/python3 shebang(s) is affected.

Indeed this PR fixes the issue for me (changing alternatives of python3 and building/using system packages)

Let's ship this then?

👍

Pull-Request has been merged by churchyard

2 years ago

Building epel-rpm-macros-8-34 for epel8-candidate
Created task: 94403055
Task info: https://koji.fedoraproject.org/koji/taskinfo?taskID=94403055