2020-04-16 13:42:50 +00:00
|
|
|
# This is a directory where wheels are stored and installed from, relative to PWD
|
2021-05-27 13:16:16 +00:00
|
|
|
%_pyproject_wheeldir %{_builddir}%{?buildsubdir:/%{buildsubdir}}/pyproject-wheeldir
|
2020-04-16 13:42:50 +00:00
|
|
|
|
|
|
|
# This is a directory used as TMPDIR, where pip copies sources to and builds from, relative to PWD
|
|
|
|
# For proper debugsource packages, we create TMPDIR within PWD
|
|
|
|
# See https://github.com/pypa/pip/issues/7555#issuecomment-595180864
|
|
|
|
#
|
|
|
|
# This will be used in debugsource package paths (applies to extension modules only)
|
|
|
|
# NB: pytest collects tests from here if not hidden
|
|
|
|
# https://docs.pytest.org/en/latest/reference.html#confval-norecursedirs
|
2021-05-27 13:16:16 +00:00
|
|
|
%_pyproject_builddir %{_builddir}%{?buildsubdir:/%{buildsubdir}}/.pyproject-builddir
|
2019-11-13 11:39:36 +00:00
|
|
|
|
2020-04-15 14:44:04 +00:00
|
|
|
%pyproject_files %{_builddir}/pyproject-files
|
2020-07-29 10:49:15 +00:00
|
|
|
%pyproject_ghost_distinfo %{_builddir}/pyproject-ghost-distinfo
|
2020-09-15 06:55:44 +00:00
|
|
|
%pyproject_record %{_builddir}/pyproject-record
|
2020-04-15 14:44:04 +00:00
|
|
|
|
2021-06-26 14:31:09 +00:00
|
|
|
# Avoid leaking %%{_pyproject_builddir} to pytest collection
|
|
|
|
# https://bugzilla.redhat.com/show_bug.cgi?id=1935212
|
|
|
|
# The value is read and used by the %%pytest and %%tox macros:
|
|
|
|
%_set_pytest_addopts %global __pytest_addopts --ignore=%{_pyproject_builddir}
|
|
|
|
|
2019-07-02 10:41:04 +00:00
|
|
|
%pyproject_wheel() %{expand:\\\
|
2021-06-26 14:31:09 +00:00
|
|
|
%_set_pytest_addopts
|
2021-05-27 13:16:16 +00:00
|
|
|
mkdir -p "%{_pyproject_builddir}"
|
|
|
|
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" TMPDIR="%{_pyproject_builddir}" \\\
|
2020-04-16 13:42:50 +00:00
|
|
|
%{__python3} -m pip wheel --wheel-dir %{_pyproject_wheeldir} --no-deps --use-pep517 --no-build-isolation --disable-pip-version-check --no-clean --progress-bar off --verbose .
|
2019-07-02 10:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
%pyproject_install() %{expand:\\\
|
2020-05-06 10:55:13 +00:00
|
|
|
specifier=$(ls %{_pyproject_wheeldir}/*.whl | xargs basename --multiple | sed -E 's/([^-]+)-([^-]+)-.+\\\.whl/\\\1==\\\2/')
|
2021-05-27 13:16:16 +00:00
|
|
|
TMPDIR="%{_pyproject_builddir}" %{__python3} -m pip install --root %{buildroot} --no-deps --disable-pip-version-check --progress-bar off --verbose --ignore-installed --no-warn-script-location --no-index --no-cache-dir --find-links %{_pyproject_wheeldir} $specifier
|
2019-07-02 14:53:05 +00:00
|
|
|
if [ -d %{buildroot}%{_bindir} ]; then
|
2020-09-04 10:31:37 +00:00
|
|
|
%py3_shebang_fix %{buildroot}%{_bindir}/*
|
2019-11-13 11:41:31 +00:00
|
|
|
rm -rfv %{buildroot}%{_bindir}/__pycache__
|
2019-07-02 10:41:04 +00:00
|
|
|
fi
|
2020-07-29 10:49:15 +00:00
|
|
|
rm -f %{pyproject_ghost_distinfo}
|
2020-09-22 11:38:34 +00:00
|
|
|
site_dirs=()
|
|
|
|
# Process %%{python3_sitelib} if exists
|
2019-07-02 14:53:05 +00:00
|
|
|
if [ -d %{buildroot}%{python3_sitelib} ]; then
|
2020-09-22 11:38:34 +00:00
|
|
|
site_dirs+=( "%{python3_sitelib}" )
|
2019-07-02 11:57:24 +00:00
|
|
|
fi
|
2020-09-22 11:38:34 +00:00
|
|
|
# Process %%{python3_sitearch} if exists and does not equal to %%{python3_sitelib}
|
2020-07-29 10:49:15 +00:00
|
|
|
if [ %{buildroot}%{python3_sitearch} != %{buildroot}%{python3_sitelib} ] && [ -d %{buildroot}%{python3_sitearch} ]; then
|
2020-09-22 11:38:34 +00:00
|
|
|
site_dirs+=( "%{python3_sitearch}" )
|
|
|
|
fi
|
|
|
|
# Process all *.dist-info dirs in sitelib/sitearch
|
|
|
|
for site_dir in ${site_dirs[@]}; do
|
|
|
|
for distinfo in %{buildroot}$site_dir/*.dist-info; do
|
2020-07-29 10:49:15 +00:00
|
|
|
echo "%ghost ${distinfo#%{buildroot}}" >> %{pyproject_ghost_distinfo}
|
|
|
|
sed -i 's/pip/rpm/' ${distinfo}/INSTALLER
|
2020-09-22 11:38:34 +00:00
|
|
|
PYTHONPATH=%{_rpmconfigdir}/redhat \\
|
|
|
|
%{__python3} -B %{_rpmconfigdir}/redhat/pyproject_preprocess_record.py \\
|
|
|
|
--buildroot %{buildroot} --record ${distinfo}/RECORD --output %{pyproject_record}
|
2020-09-29 11:04:54 +00:00
|
|
|
rm -fv ${distinfo}/RECORD
|
|
|
|
rm -fv ${distinfo}/REQUESTED
|
2020-07-29 10:49:15 +00:00
|
|
|
done
|
2020-09-22 11:38:34 +00:00
|
|
|
done
|
2020-07-29 10:49:15 +00:00
|
|
|
lines=$(wc -l %{pyproject_ghost_distinfo} | cut -f1 -d" ")
|
|
|
|
if [ $lines -ne 1 ]; then
|
2021-05-27 18:42:37 +00:00
|
|
|
echo -e "\\n\\nWARNING: %%%%pyproject_extras_subpkg won't work without explicit -i or -F, found $lines dist-info directories.\\n\\n" >&2
|
2020-07-29 10:49:15 +00:00
|
|
|
rm %{pyproject_ghost_distinfo} # any attempt to use this will fail
|
2019-07-02 14:53:05 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-04-15 14:44:04 +00:00
|
|
|
|
2020-08-04 13:08:18 +00:00
|
|
|
# Note: the three times nested questionmarked -i -f -F pattern means: If none of those options was used -- in that case, we inject our own -f
|
|
|
|
%pyproject_extras_subpkg(n:i:f:F) %{expand:%{?python_extras_subpkg:%{python_extras_subpkg%{?!-i:%{?!-f:%{?!-F: -f %{pyproject_ghost_distinfo}}}} %**}}}
|
2020-07-29 10:49:15 +00:00
|
|
|
|
|
|
|
|
2020-04-15 14:44:04 +00:00
|
|
|
%pyproject_save_files() %{expand:\\\
|
|
|
|
%{__python3} %{_rpmconfigdir}/redhat/pyproject_save_files.py \\
|
|
|
|
--output "%{pyproject_files}" \\
|
|
|
|
--buildroot "%{buildroot}" \\
|
|
|
|
--sitelib "%{python3_sitelib}" \\
|
|
|
|
--sitearch "%{python3_sitearch}" \\
|
|
|
|
--python-version "%{python3_version}" \\
|
2020-09-15 06:55:44 +00:00
|
|
|
--pyproject-record "%{pyproject_record}" \\
|
2020-04-15 14:44:04 +00:00
|
|
|
%{*}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-26 15:50:36 +00:00
|
|
|
%default_toxenv py%{python3_version_nodots}
|
|
|
|
%toxenv %{default_toxenv}
|
2019-07-26 14:15:59 +00:00
|
|
|
|
2020-04-15 14:44:04 +00:00
|
|
|
|
2019-08-13 12:42:21 +00:00
|
|
|
%pyproject_buildrequires(rxte:) %{expand:\\\
|
2020-11-03 10:29:50 +00:00
|
|
|
%{-e:%{expand:%global toxenv %(%{__python3} -s %{_rpmconfigdir}/redhat/pyproject_construct_toxenv.py %{?**})}}
|
2020-07-22 16:13:50 +00:00
|
|
|
echo 'python%{python3_pkgversion}-devel'
|
|
|
|
echo 'python%{python3_pkgversion}dist(pip) >= 19'
|
|
|
|
echo 'python%{python3_pkgversion}dist(packaging)'
|
2021-02-02 22:16:59 +00:00
|
|
|
if [ -f pyproject.toml ]; then
|
|
|
|
echo 'python%{python3_pkgversion}dist(toml)'
|
2021-02-02 22:31:44 +00:00
|
|
|
else
|
|
|
|
# Note: If the default requirements change, also change them in the script!
|
|
|
|
echo 'python%{python3_pkgversion}dist(setuptools) >= 40.8'
|
|
|
|
echo 'python%{python3_pkgversion}dist(wheel)'
|
2021-02-02 22:16:59 +00:00
|
|
|
fi
|
2020-08-14 12:57:40 +00:00
|
|
|
# Check if we can generate dependencies on Python extras
|
|
|
|
if [ "%{py_dist_name []}" == "[]" ]; then
|
|
|
|
extras_flag=%{?!_python_no_extras_requires:--generate-extras}
|
|
|
|
else
|
|
|
|
extras_flag=
|
|
|
|
fi
|
2019-07-17 16:16:16 +00:00
|
|
|
# setuptools assumes no pre-existing dist-info
|
2019-10-08 11:01:08 +00:00
|
|
|
rm -rfv *.dist-info/ >&2
|
2019-07-02 14:53:05 +00:00
|
|
|
if [ -f %{__python3} ]; then
|
2020-09-03 22:16:27 +00:00
|
|
|
RPM_TOXENV="%{toxenv}" HOSTNAME="rpmbuild" %{__python3} -s %{_rpmconfigdir}/redhat/pyproject_buildrequires.py $extras_flag --python3_pkgversion %{python3_pkgversion} %{?**}
|
2019-07-02 10:41:04 +00:00
|
|
|
fi
|
|
|
|
}
|
2019-07-26 15:50:36 +00:00
|
|
|
|
2020-04-15 14:44:04 +00:00
|
|
|
|
2019-07-26 15:50:36 +00:00
|
|
|
%tox(e:) %{expand:\\\
|
|
|
|
TOX_TESTENV_PASSENV="${TOX_TESTENV_PASSENV:-*}" \\
|
2020-11-27 15:20:16 +00:00
|
|
|
PYTHONDONTWRITEBYTECODE=1 \\
|
2019-07-26 15:50:36 +00:00
|
|
|
PATH="%{buildroot}%{_bindir}:$PATH" \\
|
|
|
|
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}" \\
|
2021-06-26 14:31:09 +00:00
|
|
|
%{?__pytest_addopts:PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} %{__pytest_addopts}"} \\
|
2020-07-15 10:15:19 +00:00
|
|
|
HOSTNAME="rpmbuild" \\
|
2020-07-21 13:20:12 +00:00
|
|
|
%{__python3} -m tox --current-env -q --recreate -e "%{-e:%{-e*}}%{!-e:%{toxenv}}" %{?*}
|
2019-07-26 15:50:36 +00:00
|
|
|
}
|