Orion Poplawski 49ccad9
# python3_pkgversion specifies the version of Python 3 in the distro.  It can be
Orion Poplawski 49ccad9
# a specific version (e.g. 34 in Fedora EPEL7)
Orion Poplawski 49ccad9
%python3_pkgversion 3
Orion Poplawski 49ccad9
Orion Poplawski 49ccad9
# Set to /bin/true to avoid %ifdefs and %{? in specfiles
Orion Poplawski 49ccad9
%__python3_other /bin/true
Orion Poplawski 49ccad9
%py3_other_build /bin/true
Orion Poplawski 49ccad9
%py3_other_install /bin/true
123ad4b
123ad4b
123ad4b
123ad4b
# === Macros for Build/Requires tags using Python dist tags ===
123ad4b
# - https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
123ad4b
# - These macros need to be in macros.python-srpm, because BuildRequires tags
123ad4b
#   get rendered as runtime requires into the metadata of SRPMs.
123ad4b
123ad4b
# Converts Python dist name to a canonical format
123ad4b
%py_dist_name() %{lua:\
123ad4b
        name = rpm.expand("%{?1:%{1}}");\
123ad4b
        canonical = string.gsub(string.lower(name), "%W+", "-");\
123ad4b
        print(canonical);\
123ad4b
}
123ad4b
123ad4b
# Creates Python 2 dist tag(s) after converting names to canonical format
123ad4b
#   Needs to first put all arguments into a list, because invoking a different
123ad4b
#   macro (%py_dist_name) overwrites them
123ad4b
%py2_dist() %{lua:\
123ad4b
        args = {}\
123ad4b
        arg = 1\
123ad4b
        while (true) do\
123ad4b
                name = rpm.expand("%{?" .. arg .. ":%{" .. arg .. "}}");\
123ad4b
                if (name == nil or name == '') then\
123ad4b
                        break\
123ad4b
                end\
123ad4b
                args[arg] = name\
123ad4b
                arg = arg + 1\
123ad4b
        end\
123ad4b
        for arg, name in ipairs(args) do\
123ad4b
                canonical = rpm.expand("%py_dist_name " .. name);\
123ad4b
                print("python2dist(" .. canonical .. ") ");\
123ad4b
        end\
123ad4b
}
123ad4b
123ad4b
# Creates Python 3 dist tag(s) after converting names to canonical format
123ad4b
#   Needs to first put all arguments into a list, because invoking a different
123ad4b
#   macro (%py_dist_name) overwrites them
123ad4b
%py3_dist() %{lua:\
123ad4b
        args = {}\
123ad4b
        arg = 1\
123ad4b
        while (true) do\
123ad4b
                name = rpm.expand("%{?" .. arg .. ":%{" .. arg .. "}}");\
123ad4b
                if (name == nil or name == '') then\
123ad4b
                        break\
123ad4b
                end\
123ad4b
                args[arg] = name\
123ad4b
                arg = arg + 1\
123ad4b
        end\
123ad4b
        for arg, name in ipairs(args) do\
123ad4b
                canonical = rpm.expand("%py_dist_name " .. name);\
123ad4b
                print("python3dist(" .. canonical .. ") ");\
123ad4b
        end\
123ad4b
}
123ad4b