Orion Poplawski ec28c77
%py_setup setup.py
Orion Poplawski ec28c77
%py_shbang_opts -s
Orion Poplawski ec28c77
Orion Poplawski ec28c77
%py_build() %{expand:\
Orion Poplawski ec28c77
CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py_shbang_opts}" %{?1}\
Orion Poplawski ec28c77
}
Orion Poplawski ec28c77
Orion Poplawski ec28c77
%py_install() %{expand:\
Orion Poplawski ec28c77
CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?1}\
Orion Poplawski ec28c77
}
Orion Poplawski ec28c77
Orion Poplawski ec28c77
%python_provide() %{lua:\
Orion Poplawski ec28c77
        function string.starts(String,Start)\
Orion Poplawski ec28c77
                return string.sub(String,1,string.len(Start))==Start\
Orion Poplawski ec28c77
        end\
Orion Poplawski ec28c77
        package = rpm.expand("%{?1:%{1}}");\
Orion Poplawski ec28c77
        vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}")
Orion Poplawski ec28c77
        if (string.starts(package, "python2-")) then\
Orion Poplawski b2fc537
                if (rpm.expand("%{?buildarch}") != "noarch") then\
Orion Poplawski b2fc537
                        str = "Provides: python-" .. string.sub(package,9,string.len(package)) .. "%{?_isa} = " .. vr;\
Orion Poplawski b2fc537
                        print(rpm.expand(str));\
Orion Poplawski b2fc537
                end\
Orion Poplawski ec28c77
                print("\\nProvides: python-");\
Orion Poplawski ec28c77
                print(string.sub(package,9,string.len(package)));\
Orion Poplawski ec28c77
                print(" = ");\
Orion Poplawski ec28c77
                print(vr);\
Orion Poplawski ec28c77
                --Obsoleting the previous default python package\
Orion Poplawski b2fc537
                if (rpm.expand("%{?buildarch}") != "noarch") then\
Orion Poplawski b2fc537
                        str = "\\nObsoletes: python-" .. string.sub(package,9,string.len(package)) .. "%{?_isa} < " .. vr;\
Orion Poplawski b2fc537
                        print(rpm.expand(str));\
Orion Poplawski b2fc537
                end\
Orion Poplawski ec28c77
                print("\\nObsoletes: python-");\
Orion Poplawski ec28c77
                print(string.sub(package,9,string.len(package)));\
Orion Poplawski ec28c77
                print(" < ");\
Orion Poplawski ec28c77
                print(vr);\
Orion Poplawski ec28c77
        elseif (string.starts(package, "python3-")) then\
Orion Poplawski ec28c77
                --No unversioned provides as python3 is not default\
Orion Poplawski ec28c77
        elseif (string.starts(package, "pypy-")) then\
Orion Poplawski ec28c77
                --No unversioned provides as pypy is not default\
Orion Poplawski ec28c77
        elseif (string.starts(package, "pypy3-")) then\
Orion Poplawski ec28c77
                --No unversioned provides as pypy is not default\
Orion Poplawski ec28c77
        elseif (string.starts(package, "python-")) then\
Orion Poplawski ec28c77
                --Providing the current default python\
Orion Poplawski ec28c77
                print("Provides: python2-");\
Orion Poplawski ec28c77
                print(string.sub(package,8,string.len(package)));\
Orion Poplawski ec28c77
                print(" = ");\
Orion Poplawski ec28c77
                print(vr);\
Orion Poplawski ec28c77
        else\
Orion Poplawski ec28c77
                print("ERROR: ");\
Orion Poplawski ec28c77
                print(package);\
Orion Poplawski ec28c77
                print("not recognized.");\
Orion Poplawski ec28c77
        end\
Orion Poplawski ec28c77
}