d38048d
# unversioned macros: used with user defined __python, no longer part of rpm >= 4.15
536b2ef
# __python is defined to error by default in the srpm macros
d38048d
%python_sitelib %(%{__python} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
d38048d
%python_sitearch %(%{__python} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")
d38048d
%python_version %(%{__python} -Esc "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))")
d38048d
%python_version_nodots %(%{__python} -Esc "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))")
d38048d
Orion Poplawski ec28c77
%py_setup setup.py
Orion Poplawski ec28c77
%py_shbang_opts -s
Orion Poplawski ec28c77
Orion Poplawski 5ca1f52
# Use the slashes after expand so that the command starts on the same line as
Orion Poplawski 5ca1f52
# the macro
Orion Poplawski 5ca1f52
%py_build() %{expand:\\\
4904408
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
90b0bf7
  %{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python} %{py_shbang_opts}" %{?*}
Orion Poplawski e7af332
  sleep 1
Orion Poplawski ec28c77
}
Orion Poplawski ec28c77
Orion Poplawski 5ca1f52
%py_build_egg() %{expand:\\\
4904408
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
4904408
  %{__python} %{py_setup} %{?py_setup_args} bdist_egg %{?*}
Orion Poplawski e7af332
  sleep 1
Orion Poplawski e7af332
}
Orion Poplawski e7af332
Orion Poplawski 5ca1f52
%py_build_wheel() %{expand:\\\
4904408
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
4904408
  %{__python} %{py_setup} %{?py_setup_args} bdist_wheel %{?*}
Orion Poplawski e7af332
  sleep 1
Orion Poplawski f798c43
}
Orion Poplawski f798c43
Orion Poplawski 5ca1f52
%py_install() %{expand:\\\
4904408
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
4904408
  %{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}
Orion Poplawski ec28c77
}
Orion Poplawski ec28c77
Orion Poplawski 5ca1f52
%py_install_egg() %{expand:\\\
Orion Poplawski f798c43
  mkdir -p %{buildroot}%{python_sitelib}
Orion Poplawski f798c43
  easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python_version}.egg %{?*}
Orion Poplawski f798c43
}
Orion Poplawski f798c43
Orion Poplawski 5ca1f52
%py_install_wheel() %{expand:\\\
d0fdb0d
  pip install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps
Orion Poplawski e7af332
}
Orion Poplawski e7af332
Orion Poplawski 29e6636
%python_provide() %{lua:
Orion Poplawski 29e6636
  function string.starts(String,Start)
Orion Poplawski 29e6636
    return string.sub(String,1,string.len(Start))==Start
Orion Poplawski 29e6636
  end
Orion Poplawski 6ce524f
  package = rpm.expand("%{?1}")
Orion Poplawski 29e6636
  vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}")
Orion Poplawski 29e6636
  if (string.starts(package, "python2-")) then
Orion Poplawski 29e6636
    print("\\nProvides: python-")
Orion Poplawski 29e6636
    print(string.sub(package,9,string.len(package)))
Orion Poplawski 29e6636
    print(" = ")
Orion Poplawski 29e6636
    print(vr)
b67b47d
    --Obsoleting the previous default python package (if it doesn't have isa)
b67b47d
    if (string.sub(package, "-1") ~= ")") then
b67b47d
      print("\\nObsoletes: python-")
b67b47d
      print(string.sub(package,9,string.len(package)))
b67b47d
      print(" < ")
b67b47d
      print(vr)
b67b47d
    end
Orion Poplawski 29e6636
  elseif (string.starts(package, "python" .. rpm.expand("%{python3_pkgversion}") .. "-")) then
Orion Poplawski 29e6636
    --No unversioned provides as python3 is not default
Orion Poplawski 29e6636
  elseif (rpm.expand("%{?python3_other_pkgversion}") ~= "" and string.starts(package, "python" .. rpm.expand("%{python3_other_pkgversion}") .. "-")) then
Orion Poplawski 29e6636
    --No unversioned provides as python3_other is not default
Orion Poplawski 29e6636
  elseif (string.starts(package, "pypy-")) then
Orion Poplawski 29e6636
    --No unversioned provides as pypy is not default
Orion Poplawski 29e6636
  elseif (string.starts(package, "pypy3-")) then
Orion Poplawski 29e6636
    --No unversioned provides as pypy is not default
Orion Poplawski 29e6636
  elseif (string.starts(package, "python-")) then
Orion Poplawski 29e6636
    --Providing the current default python
Orion Poplawski 29e6636
    print("Provides: python2-")
Orion Poplawski 29e6636
    print(string.sub(package,8,string.len(package)))
Orion Poplawski 29e6636
    print(" = ")
Orion Poplawski 29e6636
    print(vr)
Orion Poplawski 29e6636
  else
Orion Poplawski 29e6636
    print("%python_provide: ERROR: ")
Orion Poplawski 29e6636
    print(package)
Orion Poplawski 29e6636
    print(" not recognized.")
Orion Poplawski 29e6636
  end
Orion Poplawski ec28c77
}
ec476c8
9b8fac0
%python_disable_dependency_generator() \
9b8fac0
%undefine __pythondist_requires \
ec476c8
%{nil}