Bug 2169855

Summary: %pyproject_buildrequires -w fails when the build backend is already installed and pip isn't
Product: [Fedora] Fedora Reporter: Miro Hrončok <mhroncok>
Component: pyproject-rpm-macrosAssignee: Miro Hrončok <mhroncok>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: low    
Version: rawhideCC: maxwell, mhroncok, pviktori, python-packagers-sig, torsava
Target Milestone: ---Keywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pyproject-rpm-macros-1.11.0-1.fc40 pyproject-rpm-macros-1.11.0-1.fc39 pyproject-rpm-macros-1.11.0-1.fc38 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-12-14 12:59:06 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:

Description Miro Hrončok 2023-02-14 19:57:35 UTC
Description of problem:
When the %pyproject_buildrequires macro is used with the -w option (build wheel and read the metadata from it) and the build backend is already installed but pip isn't, then the build fails with:

Requirement satisfied: hatchling
   (installed: hatchling 1.13.0)
/usr/bin/python3: No module named pip
Traceback (most recent call last):
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 532, in main
    generate_requires(
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 444, in generate_requires
    generate_run_requirements(backend, requirements, build_wheel=build_wheel, wheeldir=wheeldir)
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 352, in generate_run_requirements
    generate_run_requirements_wheel(backend, requirements, wheeldir)
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 333, in generate_run_requirements_wheel
    raise RuntimeError('Failed to build the wheel for %pyproject_buildrequires -w.')
RuntimeError: Failed to build the wheel for %pyproject_buildrequires -w.


This is caused by the fact that the macro echoes pip but the %generate_buildrequires section does not restart before using it.


Version-Release number of selected component: 1.6.2-1


How reproducible: Always.

Steps to Reproduce:

1. Take e.g. https://src.fedoraproject.org/rpms/pyproject-rpm-macros/blob/rawhide/f/tests/python-userpath.spec

2. Apply this change:

 BuildRequires:  python3-devel
+BuildRequires:  python3-hatchling
...
 %generate_buildrequires
-%pyproject_buildrequires requirements-dev.txt -w
+%pyproject_buildrequires -w
...
 %check
-%pytest
+#pytest

(The requirements-dev.txt argument must be removed because it hides this problem.)

3. Build the spec in mock/koji.

Actual results:
/usr/bin/python3: No module named pip
...
RuntimeError: Failed to build the wheel for %pyproject_buildrequires -w.

Expected results:
pip is installed, package builds fine.


Additional info:
Possible fix: Before calling pyproject_wheel.build_wheel(...), requirements.add('pip', ...) and requirements.check(...).

Comment 1 Fedora Release Engineering 2023-08-16 07:06:56 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 39 development cycle.
Changing version to 39.

Comment 3 Fedora Update System 2023-12-14 12:58:18 UTC
FEDORA-2023-5c3c30efe7 has been submitted as an update to Fedora 40. https://bodhi.fedoraproject.org/updates/FEDORA-2023-5c3c30efe7

Comment 4 Fedora Update System 2023-12-14 12:59:06 UTC
FEDORA-2023-5c3c30efe7 has been pushed to the Fedora 40 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 5 Fedora Update System 2023-12-14 13:45:25 UTC
FEDORA-2023-36695c32fa has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-36695c32fa

Comment 6 Fedora Update System 2023-12-14 13:45:25 UTC
FEDORA-2023-d2fed10480 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-d2fed10480

Comment 7 Fedora Update System 2023-12-15 01:20:03 UTC
FEDORA-2023-36695c32fa has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-36695c32fa`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-36695c32fa

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

Comment 8 Fedora Update System 2023-12-15 02:36:00 UTC
FEDORA-2023-d2fed10480 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-d2fed10480`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-d2fed10480

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

Comment 9 Fedora Update System 2023-12-22 02:42:31 UTC
FEDORA-2023-36695c32fa has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 10 Fedora Update System 2023-12-27 03:16:59 UTC
FEDORA-2023-d2fed10480 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.