Adapt pyproject_install macro to PEP 610

With changes in PEP 610 there is new file direct_url.json created, since it is not useful
for us we prevent it's creation. This commit changes %pyproject_install macro to install wheel using
name instead of path.

This commit also includes new test to check if file direct_url.json wasn't created.

https://discuss.python.org/t/pep-610-usage-guidelines-for-linux-distributions/4012
This commit is contained in:
Tomas Hrnciar 2020-05-06 12:55:13 +02:00
parent 95ba8376f5
commit 19f84b1f4c
3 changed files with 10 additions and 2 deletions

View File

@ -21,8 +21,9 @@ CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" \\\
%pyproject_install() %{expand:\\\ %pyproject_install() %{expand:\\\
specifier=$(ls %{_pyproject_wheeldir}/*.whl | xargs basename --multiple | sed -E 's/([^-]+)-([^-]+)-.+\\\.whl/\\\1==\\\2/')
export TMPDIR="${PWD}/%{_pyproject_builddir}" export TMPDIR="${PWD}/%{_pyproject_builddir}"
%{__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 %{__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
if [ -d %{buildroot}%{_bindir} ]; then if [ -d %{buildroot}%{_bindir} ]; then
pathfix.py -pni "%{__python3}" -k%{?py3_shbang_opts: -a%{py3_shbang_opts_nodash}} %{buildroot}%{_bindir}/* pathfix.py -pni "%{__python3}" -k%{?py3_shbang_opts: -a%{py3_shbang_opts_nodash}} %{buildroot}%{_bindir}/*
rm -rfv %{buildroot}%{_bindir}/__pycache__ rm -rfv %{buildroot}%{_bindir}/__pycache__

View File

@ -6,7 +6,7 @@ License: MIT
# Keep the version at zero and increment only release # Keep the version at zero and increment only release
Version: 0 Version: 0
Release: 14%{?dist} Release: 15%{?dist}
# Macro files # Macro files
Source001: macros.pyproject Source001: macros.pyproject
@ -100,6 +100,9 @@ install -m 644 pyproject_save_files.py %{buildroot}%{_rpmconfigdir}/redhat/
%license LICENSE %license LICENSE
%changelog %changelog
* Thu May 07 2020 Tomas Hrnciar <thrnciar@redhat.com> - 0-15
- Adapt %%pyproject_install not to create a PEP 610 direct_url.json file
* Wed Apr 15 2020 Patrik Kopkan <pkopkan@redhat.com> - 0-14 * Wed Apr 15 2020 Patrik Kopkan <pkopkan@redhat.com> - 0-14
- Add %%pyproject_save_file macro for generating file section - Add %%pyproject_save_file macro for generating file section
- Handle extracting debuginfo from extension modules (#1806625) - Handle extracting debuginfo from extension modules (#1806625)

View File

@ -15,6 +15,7 @@ A Python package containing executables.
Building this tests: Building this tests:
- there are no bytecompiled files in %%{_bindir} - there are no bytecompiled files in %%{_bindir}
- the executable's shebang is adjusted properly - the executable's shebang is adjusted properly
- file direct_url.json isn't created
%prep %prep
%autosetup -n %{name}-%{version} %autosetup -n %{name}-%{version}
@ -36,6 +37,9 @@ test ! -d %{buildroot}%{_bindir}/__pycache__
# Internal check for our macros: tests we have a proper shebang line # Internal check for our macros: tests we have a proper shebang line
head -n1 %{buildroot}%{_bindir}/%{name}.py | grep -E '#!\s*%{python3}\s+%{py3_shbang_opts}\s*$' head -n1 %{buildroot}%{_bindir}/%{name}.py | grep -E '#!\s*%{python3}\s+%{py3_shbang_opts}\s*$'
# Internal check for our macros: tests that direct_url.json file wasn't created
test ! -e %{buildroot}%{python3_sitelib}/*.dist-info/direct_url.json
%files -f %pyproject_files %files -f %pyproject_files
%license LICENSE %license LICENSE
%doc README.md %doc README.md