Bug 2169855 - %pyproject_buildrequires -w fails when the build backend is already installed and pip isn't
Summary: %pyproject_buildrequires -w fails when the build backend is already installed...
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: pyproject-rpm-macros
Version: 39
Hardware: Unspecified
OS: Unspecified
low
unspecified
Target Milestone: ---
Assignee: Miro Hrončok
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-02-14 19:57 UTC by Miro Hrončok
Modified: 2023-08-16 07:06 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)

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.


Note You need to log in before you can comment on or make changes to this bug.