Bug 1931421

Summary: Python dist RPM generators crash with Python 3.10, deps not generated, rpmbuild proceeds
Product: [Fedora] Fedora Reporter: Miro Hrončok <mhroncok>
Component: python-rpm-generatorsAssignee: Tomas Orsava <torsava>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: cstratak, lbalhar, m.cyprian, mhroncok, ngompa13, pviktori, shcherbina.iryna, thrnciar, torsava
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-rpm-generators-12-3.fc34 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-03-19 17:37:20 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:
Bug Depends On:    
Bug Blocks: 1890881    

Description Miro Hrončok 2021-02-22 11:40:16 UTC
So, we have recently updated Python dist RPM generators in https://src.fedoraproject.org/rpms/python-rpm-generators/pull-request/30

Apparently, this fails very much with Python 3.10.0a5:

Traceback (most recent call last):
  File "/usr/lib/rpm/pythondistdeps.py", line 320, in <module>
    dist = Distribution(f)
  File "/usr/lib/rpm/pythondistdeps.py", line 56, in __init__
    self.name = self.metadata['Name']
AttributeError: can't set attribute 'name'
Traceback (most recent call last):
  File "/usr/lib/rpm/pythondistdeps.py", line 320, in <module>
    dist = Distribution(f)
  File "/usr/lib/rpm/pythondistdeps.py", line 56, in __init__
    self.name = self.metadata['Name']
AttributeError: can't set attribute 'name'


As with any other RPM dep generator, the failure does not fail the RPM build, just the provides/requires are missing.

Comment 1 Miro Hrončok 2021-02-22 11:41:44 UTC
This is a change in Python 3.10:

$ python3.9
Python 3.9.2 (default, Feb 20 2021, 00:00:00) 
...
>>> from pathlib import Path
>>> from importlib.metadata import PathDistribution
>>> class Distribution(PathDistribution):
...     def __init__(self, path):
...         super(Distribution, self).__init__(Path(path))
...         self.name = self.metadata['Name']
... 
>>> Distribution('a')
<__main__.Distribution object at 0x7f6c33e29a60>


$ python3.10
Python 3.10.0a5 (default, Feb  3 2021, 14:01:21) 
...
>>> from pathlib import Path
>>> from importlib.metadata import PathDistribution
>>> class Distribution(PathDistribution):
...     def __init__(self, path):
...         super(Distribution, self).__init__(Path(path))
...         self.name = self.metadata['Name']
... 
>>> Distribution('a')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 4, in __init__
AttributeError: can't set attribute 'name'

Comment 2 Miro Hrončok 2021-02-22 11:43:07 UTC
https://src.fedoraproject.org/rpms/python-rpm-generators/blob/rawhide/f/pythondistdeps.py#_56



A solution might be to use a wrapper class instead of inheritance.

Comment 3 Miro Hrončok 2021-02-22 15:08:37 UTC
https://src.fedoraproject.org/rpms/python-rpm-generators/pull-request/34 is used in Python 3.10 copr, hence no longer urgent.

Comment 4 Lumír Balhar 2021-02-23 09:00:17 UTC
We have found one more problem with the new generators. python3-pip provides:

… some bundled stuff …
pip = 21.0.1-1.fc35
python-pip = 21.0.1-1.fc35
python3-pip = 21.0.1-1.fc35
python3.10dist(pip) = 21.0.1
python3.9-pip = 21.0.1-1.fc35

Which is wrong. There is no python3dist(pip) which is required by all projects using pyproject-rpm-macros, and there is python3.9-pip for some unknown reason.

I'm talking about this build: https://copr.fedorainfracloud.org/coprs/g/python/python3.10/build/2014234/

Comment 5 Miro Hrončok 2021-02-23 09:13:56 UTC
> there is python3.9-pip for some unknown reason.

https://src.fedoraproject.org/rpms/python-rpm-generators/blob/rawhide/f/pythonname.attr

Comment 6 Miro Hrončok 2021-02-23 09:26:40 UTC
Both the generators use the value of %__default_python3_version to determine, well, the default Python 3 version.

When the macro is set to 3.9, python3-foo provides python3.9-foo and Python 3.10 packages *don't* provide python3dist(foo).

When the macro is set to 3.10, python3-foo provides python3.10-foo and Python 3.10 packages provide python3dist(foo).


The macro is set in the python-srpm-macros package, in the /usr/lib/rpm/macros.d/macros.python-srpm file.

In Python 3.10 copr, the package is set to build from this PR: https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/84


Yet it seems the latest build in copr was not done from that PR, but from a SRPM instead. The SRPM has version 3.10, but sets %__default_python3_version to 3.9.

Hence, the generators do what they are supposed to do.

Comment 7 Miro Hrončok 2021-02-23 09:27:43 UTC
> Yet it seems the latest build in copr was not done from that PR, but from a SRPM instead. The SRPM has version 3.10, but sets %__default_python3_version to 3.9.

https://copr.fedorainfracloud.org/coprs/g/python/python3.10/build/2013583/

Comment 8 Miro Hrončok 2021-02-23 22:03:54 UTC
(In reply to Lumír Balhar from comment #4)
> We have found one more problem with the new generators. python3-pip provides:
> 
> … some bundled stuff …
> pip = 21.0.1-1.fc35
> python-pip = 21.0.1-1.fc35
> python3-pip = 21.0.1-1.fc35
> python3.10dist(pip) = 21.0.1
> python3.9-pip = 21.0.1-1.fc35
> 
> Which is wrong. There is no python3dist(pip) which is required by all
> projects using pyproject-rpm-macros, and there is python3.9-pip for some
> unknown reason.

This was fixed.

Comment 9 Miro Hrončok 2021-02-23 22:49:17 UTC
> The SRPM has version 3.10, but sets %__default_python3_version to 3.9.

Prevention: https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/91

Comment 10 Fedora Update System 2021-03-05 22:56:10 UTC
FEDORA-2021-1bbdfbcc31 has been submitted as an update to Fedora 34. https://bodhi.fedoraproject.org/updates/FEDORA-2021-1bbdfbcc31

Comment 11 Fedora Update System 2021-03-19 17:37:20 UTC
FEDORA-2021-1bbdfbcc31 has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 12 Fedora Update System 2021-03-19 19:54:59 UTC
FEDORA-2021-1bbdfbcc31 has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.