Blame macros.pyproject

95ba837
# This is a directory where wheels are stored and installed from, relative to PWD
95ba837
%_pyproject_wheeldir pyproject-wheeldir
95ba837
95ba837
# This is a directory used as TMPDIR, where pip copies sources to and builds from, relative to PWD
95ba837
# For proper debugsource packages, we create TMPDIR within PWD
95ba837
# See https://github.com/pypa/pip/issues/7555#issuecomment-595180864
95ba837
#
95ba837
# This will be used in debugsource package paths (applies to extension modules only)
95ba837
# NB: pytest collects tests from here if not hidden
95ba837
#     https://docs.pytest.org/en/latest/reference.html#confval-norecursedirs
95ba837
%_pyproject_builddir .pyproject-builddir
49a323e
2800b49
%pyproject_files %{_builddir}/pyproject-files
2800b49
162b0ca
%pyproject_wheel() %{expand:\\\
95ba837
export TMPDIR="${PWD}/%{_pyproject_builddir}"
95ba837
mkdir -p "${TMPDIR}"
fdf5116
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" \\\
95ba837
%{__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 .
162b0ca
}
162b0ca
162b0ca
162b0ca
%pyproject_install() %{expand:\\\
19f84b1
specifier=$(ls %{_pyproject_wheeldir}/*.whl | xargs basename --multiple | sed -E 's/([^-]+)-([^-]+)-.+\\\.whl/\\\1==\\\2/')
95ba837
export TMPDIR="${PWD}/%{_pyproject_builddir}"
19f84b1
%{__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
fdf5116
if [ -d %{buildroot}%{_bindir} ]; then
dbb90f5
  pathfix.py -pni "%{__python3}" -k%{?py3_shbang_opts: -a%{py3_shbang_opts_nodash}} %{buildroot}%{_bindir}/*
8cce1fa
  rm -rfv %{buildroot}%{_bindir}/__pycache__
162b0ca
fi
fdf5116
if [ -d %{buildroot}%{python3_sitelib} ]; then
fdf5116
  sed -i 's/pip/rpm/' %{buildroot}%{python3_sitelib}/*.dist-info/INSTALLER
253976c
fi
fdf5116
if [ -d %{buildroot}%{python3_sitearch} ]; then
fdf5116
  sed -i 's/pip/rpm/' %{buildroot}%{python3_sitearch}/*.dist-info/INSTALLER
fdf5116
fi
fdf5116
}
fdf5116
2800b49
2800b49
%pyproject_save_files() %{expand:\\\
2800b49
%{__python3} %{_rpmconfigdir}/redhat/pyproject_save_files.py \\
2800b49
  --output "%{pyproject_files}" \\
2800b49
  --buildroot "%{buildroot}" \\
2800b49
  --sitelib "%{python3_sitelib}" \\
2800b49
  --sitearch "%{python3_sitearch}" \\
2800b49
  --bindir "%{_bindir}" \\
2800b49
  --python-version "%{python3_version}" \\
2800b49
  %{*}
2800b49
}
2800b49
2800b49
ec07317
%default_toxenv py%{python3_version_nodots}
ec07317
%toxenv %{default_toxenv}
0124d2a
2800b49
fda0a23
%pyproject_buildrequires(rxte:) %{expand:\\\
fda0a23
%{-e:%{expand:%global toxenv %{-e*}}}
fdf5116
echo 'python3-devel'
fdf5116
echo 'python3dist(packaging)'
ed5dd77
echo 'python3dist(toml)'
bc156c4
# setuptools assumes no pre-existing dist-info
1026263
rm -rfv *.dist-info/ >&2
fdf5116
if [ -f %{__python3} ]; then
37216e7
  RPM_TOXENV="%{toxenv}" HOSTNAME="rpmbuild" %{__python3} -I %{_rpmconfigdir}/redhat/pyproject_buildrequires.py %{?**}
162b0ca
fi
162b0ca
}
ec07317
2800b49
ec07317
%tox(e:) %{expand:\\\
ec07317
TOX_TESTENV_PASSENV="${TOX_TESTENV_PASSENV:-*}" \\
ec07317
PATH="%{buildroot}%{_bindir}:$PATH" \\
ec07317
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}" \\
37216e7
HOSTNAME="rpmbuild" \\
ec07317
tox --current-env -q --recreate -e "%{-e:%{-e*}}%{!-e:%{toxenv}}" %{?*}
ec07317
}