ae2451
%py_setup setup.py
ae2451
%py_shbang_opts -s
ae2451
ae2451
# Use the slashes after expand so that the command starts on the same line as
ae2451
# the macro
ae2451
%py_build() %{expand:\\\
ae2451
  CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py_shbang_opts}" %{?*}
ae2451
  sleep 1
ae2451
}
ae2451
ae2451
%py_build_egg() %{expand:\\\
ae2451
  CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} bdist_egg %{?*}
ae2451
  sleep 1
ae2451
}
ae2451
ae2451
%py_build_wheel() %{expand:\\\
ae2451
  CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} bdist_wheel %{?*}
ae2451
  sleep 1
ae2451
}
ae2451
ae2451
%py_install() %{expand:\\\
ae2451
  CFLAGS="%{optflags}" %{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}
ae2451
}
ae2451
ae2451
%py_install_egg() %{expand:\\\
ae2451
  mkdir -p %{buildroot}%{python_sitelib}
ae2451
  easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python_version}.egg %{?*}
ae2451
}
ae2451
ae2451
%py_install_wheel() %{expand:\\\
ae2451
  pip install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps
ae2451
}
ae2451
ae2451
%python_provide() %{lua:
ae2451
  function string.starts(String,Start)
ae2451
    return string.sub(String,1,string.len(Start))==Start
ae2451
  end
ae2451
  package = rpm.expand("%{?1}")
ae2451
  vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}")
ae2451
  if (string.starts(package, "python2-")) then
ae2451
    if (rpm.expand("%{?buildarch}") ~= "noarch") then
ae2451
      str = "Provides: python-" .. string.sub(package,9,string.len(package)) .. "%{?_isa} = " .. vr
ae2451
      print(rpm.expand(str))
ae2451
    end
ae2451
    print("\\nProvides: python-")
ae2451
    print(string.sub(package,9,string.len(package)))
ae2451
    print(" = ")
ae2451
    print(vr)
ae2451
    --Obsoleting the previous default python package
ae2451
    print("\\nObsoletes: python-")
ae2451
    print(string.sub(package,9,string.len(package)))
ae2451
    print(" < ")
ae2451
    print(vr)
ae2451
  elseif (string.starts(package, "python" .. rpm.expand("%{python3_pkgversion}") .. "-")) then
ae2451
    --No unversioned provides as python3 is not default
ae2451
  elseif (rpm.expand("%{?python3_other_pkgversion}") ~= "" and string.starts(package, "python" .. rpm.expand("%{python3_other_pkgversion}") .. "-")) then
ae2451
    --No unversioned provides as python3_other is not default
ae2451
  elseif (string.starts(package, "pypy-")) then
ae2451
    --No unversioned provides as pypy is not default
ae2451
  elseif (string.starts(package, "pypy3-")) then
ae2451
    --No unversioned provides as pypy is not default
ae2451
  elseif (string.starts(package, "python-")) then
ae2451
    --Providing the current default python
ae2451
    print("Provides: python2-")
ae2451
    print(string.sub(package,8,string.len(package)))
ae2451
    print(" = ")
ae2451
    print(vr)
ae2451
  else
ae2451
    print("%python_provide: ERROR: ")
ae2451
    print(package)
ae2451
    print(" not recognized.")
ae2451
  end
ae2451
}