8d3d1dd
%python2_sitelib %(%{__python2} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
8d3d1dd
%python2_sitearch %(%{__python2} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")
8d3d1dd
%python2_version %(%{__python2} -Esc "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))")
8d3d1dd
%python2_version_nodots %(%{__python2} -Esc "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))")
Orion Poplawski ec28c77
Orion Poplawski ec28c77
%py2_shbang_opts -s
e9f07b7
%py2_shbang_opts_nodash %(opts=%{py2_shbang_opts}; echo ${opts#-})
7237192
%py2_shebang_flags %(opts=%{py2_shbang_opts}; echo ${opts#-})
7237192
%py2_shebang_fix %{expand:/usr/bin/pathfix.py -pni %{__python2} -k%{?py2_shebang_flags:a %py2_shebang_flags}}
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
c8932dc
# The `sleep 1` commands work around a race in install; see:
c8932dc
#   https://bugzilla.redhat.com/show_bug.cgi?id=1644923
Orion Poplawski 5ca1f52
%py2_build() %{expand:\\\
c8932dc
  sleep 1
4904408
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
4904408
  %{__python2} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py2_shbang_opts}" %{?*}
Orion Poplawski 29e6636
  sleep 1
Orion Poplawski ec28c77
}
Orion Poplawski ec28c77
Orion Poplawski 5ca1f52
%py2_build_egg() %{expand:\\\
c8932dc
  sleep 1
4904408
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
4904408
  %{__python2} %{py_setup} %{?py_setup_args} bdist_egg %{?*}
Orion Poplawski e7af332
  sleep 1
Orion Poplawski e7af332
}
Orion Poplawski e7af332
Orion Poplawski 5ca1f52
%py2_build_wheel() %{expand:\\\
c8932dc
  sleep 1
4904408
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
4904408
  %{__python2} %{py_setup} %{?py_setup_args} bdist_wheel %{?*}
Orion Poplawski f798c43
  sleep 1
Orion Poplawski f798c43
}
Orion Poplawski f798c43
Orion Poplawski 5ca1f52
%py2_install() %{expand:\\\
4904408
  CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
4904408
  %{__python2} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}
2314fd9
  rm -rfv %{buildroot}%{_bindir}/__pycache__
Orion Poplawski ec28c77
}
Orion Poplawski f798c43
Orion Poplawski 5ca1f52
%py2_install_egg() %{expand:\\\
Orion Poplawski f798c43
  mkdir -p %{buildroot}%{python2_sitelib}
Orion Poplawski f798c43
  easy_install-%{python2_version} -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python2_version}.egg %{?*}
2314fd9
  rm -rfv %{buildroot}%{_bindir}/__pycache__
Orion Poplawski f798c43
}
Orion Poplawski e7af332
Orion Poplawski 5ca1f52
%py2_install_wheel() %{expand:\\\
f09ccd2
  pip%{python2_version} install -I dist/%{1} --root %{buildroot} --no-deps
2314fd9
  rm -rfv %{buildroot}%{_bindir}/__pycache__
daf7d32
  for distinfo in %{buildroot}%{python2_sitelib}/*.dist-info %{buildroot}%{python2_sitearch}/*.dist-info; do
daf7d32
    if [ -f ${distinfo}/direct_url.json ]; then
daf7d32
      rm -fv ${distinfo}/direct_url.json
daf7d32
      sed -i '/direct_url.json/d' ${distinfo}/RECORD
daf7d32
    fi
daf7d32
  done
Orion Poplawski e7af332
}