d38048
# unversioned macros: used with user defined __python, no longer part of rpm >= 4.15
536b2e
# __python is defined to error by default in the srpm macros
d38048
%python_sitelib %(%{__python} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
d38048
%python_sitearch %(%{__python} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")
d38048
%python_version %(%{__python} -Esc "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))")
d38048
%python_version_nodots %(%{__python} -Esc "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))")
d38048
Orion Poplawski ec28c7
%py_setup setup.py
Orion Poplawski ec28c7
%py_shbang_opts -s
Orion Poplawski ec28c7
Orion Poplawski 5ca1f5
# Use the slashes after expand so that the command starts on the same line as
Orion Poplawski 5ca1f5
# the macro
Orion Poplawski 5ca1f5
%py_build() %{expand:\\\
490440
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
90b0bf
  %{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python} %{py_shbang_opts}" %{?*}
Orion Poplawski e7af33
  sleep 1
Orion Poplawski ec28c7
}
Orion Poplawski ec28c7
Orion Poplawski 5ca1f5
%py_build_egg() %{expand:\\\
490440
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
490440
  %{__python} %{py_setup} %{?py_setup_args} bdist_egg %{?*}
Orion Poplawski e7af33
  sleep 1
Orion Poplawski e7af33
}
Orion Poplawski e7af33
Orion Poplawski 5ca1f5
%py_build_wheel() %{expand:\\\
490440
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
490440
  %{__python} %{py_setup} %{?py_setup_args} bdist_wheel %{?*}
Orion Poplawski e7af33
  sleep 1
Orion Poplawski f798c4
}
Orion Poplawski f798c4
Orion Poplawski 5ca1f5
%py_install() %{expand:\\\
490440
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
490440
  %{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}
2314fd
  rm -rfv %{buildroot}%{_bindir}/__pycache__
Orion Poplawski ec28c7
}
Orion Poplawski ec28c7
Orion Poplawski 5ca1f5
%py_install_egg() %{expand:\\\
Orion Poplawski f798c4
  mkdir -p %{buildroot}%{python_sitelib}
Orion Poplawski f798c4
  easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python_version}.egg %{?*}
2314fd
  rm -rfv %{buildroot}%{_bindir}/__pycache__
Orion Poplawski f798c4
}
Orion Poplawski f798c4
Orion Poplawski 5ca1f5
%py_install_wheel() %{expand:\\\
d0fdb0
  pip install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps
2314fd
  rm -rfv %{buildroot}%{_bindir}/__pycache__
Orion Poplawski e7af33
}
Orion Poplawski e7af33
Orion Poplawski 29e663
%python_provide() %{lua:
Orion Poplawski 29e663
  function string.starts(String,Start)
Orion Poplawski 29e663
    return string.sub(String,1,string.len(Start))==Start
Orion Poplawski 29e663
  end
Orion Poplawski 6ce524
  package = rpm.expand("%{?1}")
Orion Poplawski 29e663
  vr = rpm.expand("%{?epoch:%{epoch}:}%{version}-%{release}")
Orion Poplawski 29e663
  if (string.starts(package, "python2-")) then
64119c
    --No unversioned provides as python2 is not default
64119c
  elseif (string.starts(package, "python" .. rpm.expand("%{python3_pkgversion}") .. "-")) then
Orion Poplawski 29e663
    print("\\nProvides: python-")
64119c
    l = 8 + string.len(rpm.expand("%{python3_pkgversion}"))
64119c
    print(string.sub(package,l,string.len(package)))
Orion Poplawski 29e663
    print(" = ")
Orion Poplawski 29e663
    print(vr)
b67b47
    --Obsoleting the previous default python package (if it doesn't have isa)
b67b47
    if (string.sub(package, "-1") ~= ")") then
b67b47
      print("\\nObsoletes: python-")
64119c
      print(string.sub(package,l,string.len(package)))
b67b47
      print(" < ")
b67b47
      print(vr)
b67b47
    end
Orion Poplawski 29e663
  elseif (rpm.expand("%{?python3_other_pkgversion}") ~= "" and string.starts(package, "python" .. rpm.expand("%{python3_other_pkgversion}") .. "-")) then
Orion Poplawski 29e663
    --No unversioned provides as python3_other is not default
Orion Poplawski 29e663
  elseif (string.starts(package, "pypy-")) then
Orion Poplawski 29e663
    --No unversioned provides as pypy is not default
64119c
  elseif (string.starts(package, "pypy2-")) then
64119c
    --No unversioned provides as pypy is not default
Orion Poplawski 29e663
  elseif (string.starts(package, "pypy3-")) then
Orion Poplawski 29e663
    --No unversioned provides as pypy is not default
Orion Poplawski 29e663
  elseif (string.starts(package, "python-")) then
64119c
    --No unversioned provides needed for unversioned python
Orion Poplawski 29e663
  else
Orion Poplawski 29e663
    print("%python_provide: ERROR: ")
Orion Poplawski 29e663
    print(package)
Orion Poplawski 29e663
    print(" not recognized.")
Orion Poplawski 29e663
  end
Orion Poplawski ec28c7
}
ec476c
9b8fac
%python_disable_dependency_generator() \
9b8fac
%undefine __pythondist_requires \
ec476c
%{nil}