python-rpm-macros/macros.python2
2020-12-09 11:39:08 +01:00

65 lines
2.6 KiB
Plaintext

%python2_sitelib %(%{__python2} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
%python2_sitearch %(%{__python2} -Esc "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")
%python2_version %(%{__python2} -Esc "import sys; sys.stdout.write('{0.major}.{0.minor}'.format(sys.version_info))")
%python2_version_nodots %(%{__python2} -Esc "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))")
%python2_platform %(%{__python2} -Esc "import sysconfig; print(sysconfig.get_platform())")
%py2_shbang_opts -s
%py2_shbang_opts_nodash %(opts=%{py2_shbang_opts}; echo ${opts#-})
%py2_shebang_flags %(opts=%{py2_shbang_opts}; echo ${opts#-})
%py2_shebang_fix %{expand:\\\
if [ -z "%{?py_shebang_flags}" ]; then
shebang_flags="-k"
else
shebang_flags="-ka%{py2_shebang_flags}"
fi
/usr/bin/pathfix.py -pni %{__python2} $shebang_flags}
# Use the slashes after expand so that the command starts on the same line as
# the macro
# The `sleep 1` commands work around a race in install; see:
# https://bugzilla.redhat.com/show_bug.cgi?id=1644923
%py2_build() %{expand:\\\
sleep 1
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
%{__python2} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py2_shbang_opts}" %{?*}
sleep 1
}
%py2_build_egg() %{expand:\\\
sleep 1
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
%{__python2} %{py_setup} %{?py_setup_args} bdist_egg %{?*}
sleep 1
}
%py2_build_wheel() %{expand:\\\
sleep 1
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
%{__python2} %{py_setup} %{?py_setup_args} bdist_wheel %{?*}
sleep 1
}
%py2_install() %{expand:\\\
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\
%{__python2} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}
rm -rfv %{buildroot}%{_bindir}/__pycache__
}
%py2_install_egg() %{expand:\\\
mkdir -p %{buildroot}%{python2_sitelib}
%{__python2} -m easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python2_version}.egg %{?*}
rm -rfv %{buildroot}%{_bindir}/__pycache__
}
%py2_install_wheel() %{expand:\\\
%{__python2} -m pip install -I dist/%{1} --root %{buildroot} --no-deps --no-index --no-warn-script-location
rm -rfv %{buildroot}%{_bindir}/__pycache__
for distinfo in %{buildroot}%{python2_sitelib}/*.dist-info %{buildroot}%{python2_sitearch}/*.dist-info; do
if [ -f ${distinfo}/direct_url.json ]; then
rm -fv ${distinfo}/direct_url.json
sed -i '/direct_url.json/d' ${distinfo}/RECORD
fi
done
}