#14 EPEL 7: backport %pycached
Merged a year ago by churchyard. Opened a year ago by churchyard.
rpms/ churchyard/epel-rpm-macros epel7-pymacros  into  epel7

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

  Name:           epel-rpm-macros

  Version:        7

- Release:        23

+ Release:        24

  Summary:        Extra Packages for Enterprise Linux RPM macros

  

  Group:          System Environment/Base
@@ -52,6 +52,9 @@ 

  

  

  %changelog

+ * Sat Dec 28 2019 Miro Hrončok <mhroncok@redhat.com> - 7-24

+ - Add the %%pycached macro

+ 

  * Tue Oct 22 2019 Miro Hrončok <mhroncok@redhat.com> - 7-23

  - Override %%py_build from RHEL not to use %%__python2 but %%__python

  

file modified
+19
@@ -52,6 +52,25 @@ 

    FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \

    LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS

  

+ # This only supports Python 3.5+ and will never work with Python 2.

+ # Hence, it has no Python version in the name.

+ %pycached() %{lua:

+   path = rpm.expand("%{?1}")

+   if (string.sub(path, "-3") ~= ".py") then

+     rpm.expand("%{error:%%pycached can only be used with paths explicitly ending with .py}")

+   else

+     print(path)

+     pyminor = path:match("/python3.(%d+)/") or "*"

+     if ((pyminor ~= "*") and (tonumber(pyminor) < 5)) then

+       rpm.expand("%{error:%%pycached does not support Python 3." .. pyminor .. "}")

+     else

+       dirname = path:match("(.*/)")

+       modulename = path:match(".*/([^/]+).py")

+       print("\\n" .. dirname .. "__pycache__/" .. modulename .. ".cpython-3" .. pyminor .. "{,.opt-?}.pyc")

+     end

+   end

+ }

+ 

  # gpgverify verifies signed sources. There is documentation in the script.

  %gpgverify %{_rpmconfigdir}/gpgverify

  

no initial comment

this if is different from Fedora

The code looks reasonable.
However, ideally this should be reviewed by an experienced EPEL packager who has an idea of what could go wrong. I'm definitely not familiar enough with EPEL, and don't particularly want to become familiar enough.

rebased onto 2853346

a year ago

Based on the revived discussion on epel-devel, I've removed %python and only kept %pycached in this PR.

I have reviewed this, and it looks good to me.
+1

Pull-Request has been merged by churchyard

a year ago