This macro save generates file section to %pyproject_files. It should simplify %files section and allow to build by some automatic machinery Supposed use case in Fedora: %install %pyproject_install %pyproject_save_files requests _requests %files -n python3-requests -f %{pyproject_files} %doc README.rst %license LICENSE Automatic build of arbitrary packages (e.g. in Copr): %install %pyproject_install %pyproject_save_files * +bindir // save all modules with executables %files -n python3-requests -f %{pyproject_files} Co-Authored-By: Miro Hrončok <miro@hroncok.cz>
61 lines
2.0 KiB
Plaintext
61 lines
2.0 KiB
Plaintext
%_pyproject_wheeldir ./pyproject-macros-wheeldir
|
|
|
|
%pyproject_files %{_builddir}/pyproject-files
|
|
|
|
%pyproject_wheel() %{expand:\\\
|
|
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" \\\
|
|
%{__python3} -m pip wheel --wheel-dir %{_pyproject_wheeldir} --no-deps --use-pep517 --no-build-isolation --disable-pip-version-check --progress-bar off --verbose .
|
|
}
|
|
|
|
|
|
%pyproject_install() %{expand:\\\
|
|
%{__python3} -m pip install --root %{buildroot} --no-deps --disable-pip-version-check --progress-bar off --verbose --ignore-installed --no-warn-script-location %{_pyproject_wheeldir}/*.whl
|
|
if [ -d %{buildroot}%{_bindir} ]; then
|
|
pathfix.py -pni "%{__python3}" -k%{?py3_shbang_opts: -a%{py3_shbang_opts_nodash}} %{buildroot}%{_bindir}/*
|
|
rm -rfv %{buildroot}%{_bindir}/__pycache__
|
|
fi
|
|
if [ -d %{buildroot}%{python3_sitelib} ]; then
|
|
sed -i 's/pip/rpm/' %{buildroot}%{python3_sitelib}/*.dist-info/INSTALLER
|
|
fi
|
|
if [ -d %{buildroot}%{python3_sitearch} ]; then
|
|
sed -i 's/pip/rpm/' %{buildroot}%{python3_sitearch}/*.dist-info/INSTALLER
|
|
fi
|
|
}
|
|
|
|
|
|
%pyproject_save_files() %{expand:\\\
|
|
%{__python3} %{_rpmconfigdir}/redhat/pyproject_save_files.py \\
|
|
--output "%{pyproject_files}" \\
|
|
--buildroot "%{buildroot}" \\
|
|
--sitelib "%{python3_sitelib}" \\
|
|
--sitearch "%{python3_sitearch}" \\
|
|
--bindir "%{_bindir}" \\
|
|
--python-version "%{python3_version}" \\
|
|
%{*}
|
|
}
|
|
|
|
|
|
%default_toxenv py%{python3_version_nodots}
|
|
%toxenv %{default_toxenv}
|
|
|
|
|
|
%pyproject_buildrequires(rxte:) %{expand:\\\
|
|
%{-e:%{expand:%global toxenv %{-e*}}}
|
|
echo 'python3-devel'
|
|
echo 'python3dist(packaging)'
|
|
echo 'python3dist(pytoml)'
|
|
# setuptools assumes no pre-existing dist-info
|
|
rm -rfv *.dist-info/ >&2
|
|
if [ -f %{__python3} ]; then
|
|
RPM_TOXENV="%{toxenv}" %{__python3} -I %{_rpmconfigdir}/redhat/pyproject_buildrequires.py %{?**}
|
|
fi
|
|
}
|
|
|
|
|
|
%tox(e:) %{expand:\\\
|
|
TOX_TESTENV_PASSENV="${TOX_TESTENV_PASSENV:-*}" \\
|
|
PATH="%{buildroot}%{_bindir}:$PATH" \\
|
|
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}" \\
|
|
tox --current-env -q --recreate -e "%{-e:%{-e*}}%{!-e:%{toxenv}}" %{?*}
|
|
}
|