#39 Fedora 30: %python, %pycached
Merged 4 years ago by pviktori. Opened 4 years ago by churchyard.
rpms/ churchyard/python-rpm-macros f30-sync  into  f30

file modified
+10
@@ -11,6 +11,16 @@ 

  %python2 %__python2

  %python3 %__python3

  

+ # Users can use %%python only if they redefined %%__python (e.g. to %%__python3)

+ %python() %{lua:\

+     __python = rpm.expand("%__python")\

+     if __python == "/usr/bin/python" then\

+         rpm.expand("%{error:Cannot use %%python if %%__python wasn't redefined to something other than /usr/bin/python.}")\

+     else\

+         print(__python)\

+     end\

+ }

+ 

  # python3_pkgversion specifies the version of Python 3 in the distro.  It can be

  # a specific version (e.g. 34 in Fedora EPEL7)

  %python3_pkgversion 3

file modified
+15
@@ -37,3 +37,18 @@ 

  %py3_install_wheel() %{expand:\\\

    pip%{python3_version} install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps

  }

+ 

+ # 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 "*"

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

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

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

+   end

+ }

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

  Name:           python-rpm-macros

  Version:        3

- Release:        43%{?dist}

+ Release:        44%{?dist}

  Summary:        The unversioned Python RPM macros

  

  License:        MIT
@@ -73,6 +73,10 @@ 

  

  

  %changelog

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

+ - Define %%python, but make it work only if %%__python is redefined

+ - Add the %%pycached macro

+ 

  * Fri Sep 27 2019 Miro Hrončok <mhroncok@redhat.com> - 3-43

  - Define %%python2 and %%python3

  

no initial comment

+1.
Code looks good; Setuptools, Django, Numpy build without problems.

Pull-Request has been merged by pviktori

4 years ago