Bug 2097535

Summary: Package information on ELF objects clashes with %pyproject_buildrequires when extension modules are built
Product: [Fedora] Fedora Reporter: Jakub Kadlčík <jkadlcik>
Component: pyproject-rpm-macrosAssignee: Miro Hrončok <mhroncok>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: code, mhroncok, pviktori, python-sig, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pyproject-rpm-macros-1.3.2-1.fc37 pyproject-rpm-macros-1.3.2-1.fc35 pyproject-rpm-macros-1.3.2-1.fc36 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-06-20 13:46:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Spec file none

Description Jakub Kadlčík 2022-06-15 22:04:15 UTC
Created attachment 1890457 [details]
Spec file

Description of problem:
The %pyproject_buildrequires macro fails with gcc errors


Version-Release number of selected component (if applicable):
1.3.1-1.fc37


How reproducible:
Always


Steps to Reproduce:
1. Download the attached spec file
2. Uncomment the %pyproject_buildrequires line
3. rpmbuild -bs ~/rpmbuild/SPECS/python-pywlroots.spec
4. mock -r fedora-rawhide-x86_64 ~/rpmbuild/SRPMS/python-pywlroots-0.15.17-1.fc35.src.rpm


Actual results:
See the attached build log


Expected results:
A working build


Additional info:
Per suggestion from @mhayden I specified all the BuildRequires manually and removed the %pyproject_buildrequires macro, and the package builds successfully.

Comment 1 Jakub Kadlčík 2022-06-15 22:05:00 UTC
Created attachment 1890458 [details]
Build log

Comment 2 Miro Hrončok 2022-06-15 23:41:07 UTC
The macros execute what is given to them in upstream code. Here, they call the setup.py script through the setuptools.build_meta build backend specified in pyproject.toml.

My guess is that https://fedoraproject.org/wiki/Changes/Package_information_on_ELF_objects is not correctly handled in the %pyproject_buildrequires section.



Anyway, I fail to reproduce because of:


No matching package to install: 'python3dist(xkbcommon) >= 0.2'

Comment 3 Miro Hrončok 2022-06-15 23:42:29 UTC
Actually:

No matching package to install: 'python3dist(pywayland) >= 0.1.1'
No matching package to install: 'python3dist(xkbcommon) >= 0.2'

Comment 4 Jakub Kadlčík 2022-06-15 23:46:52 UTC
My bad, sorry about that. 
The dependencies are available in this Copr project
https://copr.fedorainfracloud.org/coprs/frostyx/qtile/

Comment 5 Miro Hrončok 2022-06-15 23:49:52 UTC
Will try. In the meantime, several notes about the spec file, some of them might be relevant to the problem.


Requires:  wlroots -> this line does nothing because it is not in the python3-pywlroots %package section.


python3 -m build --wheel --no-isolation -> this should not be needed at all because %pyproject_wheel does that instead.


python3 wlroots/ffi_build.py -> if this is *required* and not just convenient, the upstream build is not PEP 517 compatible and thus cannot work wth the pyproject macros.


%pyproject_save_files '*' +auto -> this is forbidden in official Fedora packages.

Comment 6 Miro Hrončok 2022-06-15 23:55:37 UTC
https://fedoraproject.org/wiki/Changes/Package_information_on_ELF_objects is not correctly handled in %pyproject_buildrequires -- this will bite any package that builds extension modules in %pyproject_buildrequires -- e.g. any package using %pyproject_buildrequires -w.

This works around the problem:

%undefine _package_note_flags

And this is a specfile that works:




Name:           python-pywlroots
Version:        0.15.17
Release:        1%{?dist}
Summary:        Python binding to the wlroots library using cffi

License:        MIT
URL:            https://github.com/flacjacket/pywlroots
Source:         %{pypi_source pywlroots}

BuildRequires:  python3-devel
BuildRequires:  gcc
BuildRequires:  wlroots-devel >= 0.15

# https://bugzilla.redhat.com/show_bug.cgi?id=2097535
%undefine _package_note_flags

%global _description %{expand:
A Python binding to the wlroots library using cffi. The library uses pywayland
to provide the Wayland bindings and python-xkbcommon to provide wlroots
keyboard functionality.}


%description %_description

%package -n     python3-pywlroots
Summary:        %{summary}
Requires:       wlroots

%description -n python3-pywlroots %_description


%prep
%autosetup -p1 -n pywlroots-%{version}


%generate_buildrequires
%pyproject_buildrequires


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files '*' +auto


%check
%pyproject_check_import -t


%files -n python3-pywlroots -f %{pyproject_files}

Comment 7 Miro Hrončok 2022-06-16 00:00:59 UTC
Zbyszek,

the %pyproject_buildrequires macro is to be executed in the %generate_buildrequires section. It contains:
	
    # The _auto_set_build_flags feature does not do this in %%generate_buildrequires section,
    # but we want to get an environment consistent with %%build:
    %{?_auto_set_build_flags:%set_build_flags}

We need all the flags set as they are in %build, in order to generate extension modules that are ready to be installed if needed.

However, package information on ELF objects makes this blow up when extension modules are actually built, with:

/usr/bin/ld: cannot open linker script file /builddir/build/BUILD/pywlroots-0.15.17/.package_note-python-pywlroots-0.15.17-1.fc37.x86_64.ld: No such file or directory


Do we also need to stick something like this in?

    %{?_package_note_flags:%_generate_package_note_file}

Is that idempotent?

Comment 8 Miro Hrončok 2022-06-16 09:59:31 UTC
Ok, this works:

%generate_buildrequires
%{?_package_note_flags:%_generate_package_note_file}
%pyproject_buildrequires


And this also works:

%generate_buildrequires
%{?_package_note_flags:%_generate_package_note_file}
%{?_package_note_flags:%_generate_package_note_file}
%{?_package_note_flags:%_generate_package_note_file}
%{?_package_note_flags:%_generate_package_note_file}
%{?_package_note_flags:%_generate_package_note_file}
%pyproject_buildrequires


So I think it is safe to add it.

Comment 10 Fedora Update System 2022-06-20 13:43:10 UTC
FEDORA-2022-d857c5b521 has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2022-d857c5b521

Comment 11 Fedora Update System 2022-06-20 13:46:01 UTC
FEDORA-2022-d857c5b521 has been pushed to the Fedora 37 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 12 Fedora Update System 2022-06-20 14:09:14 UTC
FEDORA-2022-49880f29f9 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-49880f29f9

Comment 13 Fedora Update System 2022-06-20 14:09:15 UTC
FEDORA-2022-de6aa089a7 has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2022-de6aa089a7

Comment 14 Fedora Update System 2022-06-21 01:29:57 UTC
FEDORA-2022-49880f29f9 has been pushed to the Fedora 36 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-49880f29f9`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-49880f29f9

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 15 Fedora Update System 2022-06-21 01:58:38 UTC
FEDORA-2022-de6aa089a7 has been pushed to the Fedora 35 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2022-de6aa089a7`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2022-de6aa089a7

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 16 Fedora Update System 2022-06-29 01:50:43 UTC
FEDORA-2022-de6aa089a7 has been pushed to the Fedora 35 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 17 Fedora Update System 2022-06-29 02:06:56 UTC
FEDORA-2022-49880f29f9 has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.