[1040] | 1 | # python3_pkgversion specifies the version of Python 3 in the distro. It can be
|
---|
| 2 | # a specific version (e.g. 34 in Fedora EPEL7)
|
---|
| 3 | %python3_pkgversion 3
|
---|
| 4 |
|
---|
| 5 | # Set to /bin/true to avoid %ifdefs and %{? in specfiles
|
---|
| 6 | %__python3_other /@unixroot/usr/bin/true
|
---|
| 7 | %py3_other_build /@unixroot/usr/bin/true
|
---|
| 8 | %py3_other_install /@unixroot/usr/bin/true
|
---|
| 9 |
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | # === Macros for Build/Requires tags using Python dist tags ===
|
---|
| 13 | # - https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
|
---|
| 14 | # - These macros need to be in macros.python-srpm, because BuildRequires tags
|
---|
| 15 | # get rendered as runtime requires into the metadata of SRPMs.
|
---|
| 16 |
|
---|
| 17 | # Converts Python dist name to a canonical format
|
---|
| 18 | %py_dist_name() %{lua:\
|
---|
| 19 | name = rpm.expand("%{?1:%{1}}");\
|
---|
| 20 | canonical = string.gsub(string.lower(name), "%W+", "-");\
|
---|
| 21 | print(canonical);\
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | # Creates Python 2 dist tag(s) after converting names to canonical format
|
---|
| 25 | # Needs to first put all arguments into a list, because invoking a different
|
---|
| 26 | # macro (%py_dist_name) overwrites them
|
---|
| 27 | %py2_dist() %{lua:\
|
---|
| 28 | args = {}\
|
---|
| 29 | arg = 1\
|
---|
| 30 | while (true) do\
|
---|
| 31 | name = rpm.expand("%{?" .. arg .. ":%{" .. arg .. "}}");\
|
---|
| 32 | if (name == nil or name == '') then\
|
---|
| 33 | break\
|
---|
| 34 | end\
|
---|
| 35 | args[arg] = name\
|
---|
| 36 | arg = arg + 1\
|
---|
| 37 | end\
|
---|
| 38 | for arg, name in ipairs(args) do\
|
---|
| 39 | canonical = rpm.expand("%py_dist_name " .. name);\
|
---|
| 40 | print("python2dist(" .. canonical .. ") ");\
|
---|
| 41 | end\
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | # Creates Python 3 dist tag(s) after converting names to canonical format
|
---|
| 45 | # Needs to first put all arguments into a list, because invoking a different
|
---|
| 46 | # macro (%py_dist_name) overwrites them
|
---|
| 47 | %py3_dist() %{lua:\
|
---|
| 48 | args = {}\
|
---|
| 49 | arg = 1\
|
---|
| 50 | while (true) do\
|
---|
| 51 | name = rpm.expand("%{?" .. arg .. ":%{" .. arg .. "}}");\
|
---|
| 52 | if (name == nil or name == '') then\
|
---|
| 53 | break\
|
---|
| 54 | end\
|
---|
| 55 | args[arg] = name\
|
---|
| 56 | arg = arg + 1\
|
---|
| 57 | end\
|
---|
| 58 | for arg, name in ipairs(args) do\
|
---|
| 59 | canonical = rpm.expand("%py_dist_name " .. name);\
|
---|
| 60 | print("python3dist(" .. canonical .. ") ");\
|
---|
| 61 | end\
|
---|
| 62 | }
|
---|