Bug 2166888
| Summary: | %pyproject_buildrequires leaks output from subprocesses to stdout, creating bogus BuildRequires | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Miro Hrončok <mhroncok> |
| Component: | pyproject-rpm-macros | Assignee: | Miro Hrončok <mhroncok> |
| Status: | CLOSED ERRATA | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | rawhide | CC: | maxwell, mhroncok, pviktori, python-packagers-sig |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | pyproject-rpm-macros-1.6.1-1.fc38 pyproject-rpm-macros-1.6.1-1.fc37 pyproject-rpm-macros-1.6.2-1.fc36 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2023-02-07 10:27:15 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: | |||
A WIP pull request in https://src.fedoraproject.org/rpms/pyproject-rpm-macros/pull-request/353 FEDORA-2023-e710cff39f has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-e710cff39f FEDORA-2023-e710cff39f has been pushed to the Fedora 38 stable repository. If problem still persists, please make note of it in this bug report. FEDORA-2023-b9d9b8dfae has been submitted as an update to Fedora 37. https://bodhi.fedoraproject.org/updates/FEDORA-2023-b9d9b8dfae FEDORA-2023-f706deb47c has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2023-f706deb47c FEDORA-2023-b9d9b8dfae has been pushed to the Fedora 37 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-b9d9b8dfae` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-b9d9b8dfae See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates. FEDORA-2023-f706deb47c 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 --refresh --advisory=FEDORA-2023-f706deb47c` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-f706deb47c See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates. FEDORA-2023-b9d9b8dfae has been pushed to the Fedora 37 stable repository. If problem still persists, please make note of it in this bug report. FEDORA-2023-f706deb47c 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 --refresh --advisory=FEDORA-2023-f706deb47c` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-f706deb47c See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates. FEDORA-2023-f706deb47c has been pushed to the Fedora 36 stable repository. If problem still persists, please make note of it in this bug report. |
The %pyproject_buildrequires macro is designed to be used in the %generate_buildrequires section. As such the entire stdout is treated as BuildRequires. Anything the macro needs to put into the logs must be put to stderr. Since this macro calls third-party code, the implementation in pyproject_buildrequires.py uses contextlib.redirect_stdout to redirect all stdout from PEP 517 hooks to stderr. Using contextlib.redirect_stdout however has limitations. It does not redirect stdout of subprocesses. If a setup.py script has for example: rv = os.system('/usr/bin/patch -N -p3 -d build/lib < lib/py-lmdb/env-copy-txn.patch') (From https://github.com/jnwatson/py-lmdb/blob/py-lmdb_1.0.0/setup.py#L117) The stdout of /usr/bin/patch leaks to stdout of %pyproject_buildrequires: [lmdb-1.0.0]$ /usr/bin/python3 -Bs /usr/lib/rpm/redhat/pyproject_buildrequires.py --python3_pkgversion 3 2>/dev/null python3dist(setuptools) >= 40.8 python3dist(wheel) patching file lmdb.h patching file mdb.c python3dist(wheel) patching file lmdb.h patching file mdb.c This results in DNF errors like this: No matching package to install: 'lmdb.h' No matching package to install: 'mdb.c' No matching package to install: 'patching' Moreover, it results in bogus BuildRequires that may exist (e.g. "file"). To fix this from within pyproject_buildrequires.py, we might need to play with file descriptors. Alternatively, we might write the desired BuildRequires to a file instead of stdout and run the script with >&2 from within the macro, catting the generated file to stdout at the end.