Bug 2018809

Summary: Regression: %py3_check_import no longer accepts arguments on multiple lines
Product: [Fedora] Fedora Reporter: Ben Beasley <code>
Component: python-rpm-macrosAssignee: Karolina Surma <ksurma>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: cstratak, j, ksurma, m.cyprian, mhroncok, pviktori, python-maint, python-sig
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-rpm-macros-3.10-13.fc36 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-03 11:11:50 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 Ben Beasley 2021-10-31 12:10:50 UTC
Description of problem:

In pyproject-rpm-macros-0-49, passing a large number of arguments to %py3_check_import on multiple lines no longer works:

> %{py3_check_import foo
>     bar
>     bat
>     baz}

This was useful for packages that had a huge number of mostly-independent submodules to test-import but preferred not to invoke %py3_check_import many times (since a single invocation improves performance and reduces clutter in the build log).

This regression will cause several packages to FTBFS if it reaches stable releases.

Version-Release number of selected component (if applicable): 0-49


How reproducible:


Steps to Reproduce:
1. Find or make a package that uses %py3_check_import this way. For example, see python-hdfs in Fedora 35, 34, or 33.
2. Build with pyproject-rpm-macros-0-49 (currently: fedpkg mockbuild --enablerepo=local).

Actual results:

Build fails with an error message mentioning the first module that is listed on a line after %py3_check_import, e.g.:

> + /usr/bin/python3 -s /usr/lib/rpm/redhat/import_all_modules.py hdfs
> Check import: hdfs
> + hdfs.client
> /var/tmp/rpm-tmp.LsRHaZ: line 40: hdfs.client: command not found

Expected results:

Build succeeds.

Additional info:

This was first noted in the following comment: https://bugzilla.redhat.com/show_bug.cgi?id=2018551#c4

Bodhi updates for pyproject-rpm-macros-0-49:

F36: https://bodhi.fedoraproject.org/updates/FEDORA-2021-6d843c39b0
F35: https://bodhi.fedoraproject.org/updates/FEDORA-2021-fd8d8c5f66
F34: https://bodhi.fedoraproject.org/updates/FEDORA-2021-22b68be2d5
F33: https://bodhi.fedoraproject.org/updates/FEDORA-2021-d085ce09ef

Comment 1 Ben Beasley 2021-10-31 12:21:59 UTC
By grepping spec files with

> rg '%\{py3_check_import.*[^}]$'

I think the affected packages will be:

- python-opencensus-proto
- python-hdfs
- python-googleapis-common-protos (also affected by https://bugzilla.redhat.com/show_bug.cgi?id=2018551)

Workarounds include:

  - Call %py3_check_import many times
  - Accept a (perhaps very) long line in the spec file
  - Switch to %pyproject_check_import (ideal!)

Comment 2 Miro HronĨok 2021-10-31 23:10:08 UTC
A fix is probably to wrap this %{?**} [0] with some Lua, previous implementation used %{lua:local m=rpm.expand('%{?*}'):gsub('[%s,]+', ', ');print(m)} [1], this could be simpler ...gsub('%s+', ' '))

[0] https://src.fedoraproject.org/rpms/python-rpm-macros/blob/2d0673afb17814e4bd6b7a281574b1d0e1fdb3e3/f/macros.python3#_80
[1] https://src.fedoraproject.org/rpms/python-rpm-macros/blob/9b797df44dc6c184c5181f10bee24461287f84f3/f/macros.python3#_78

Comment 4 Fedora Update System 2021-11-03 11:10:04 UTC
FEDORA-2021-70e7a5dae0 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2021-70e7a5dae0

Comment 5 Fedora Update System 2021-11-03 11:11:50 UTC
FEDORA-2021-70e7a5dae0 has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.