scripts/pythondistdeps: Fix for Python 3.10
self.name in PathDistribution is a property in Python 3.10+ and thus we can't redefine it as an instance variable. Instead we explicitly define it as a property, which works on all supported Python versions.
This commit is contained in:
parent
438d8d3b70
commit
48510eebae
@ -1,7 +1,7 @@
|
|||||||
Name: python-rpm-generators
|
Name: python-rpm-generators
|
||||||
Summary: Dependency generators for Python RPMs
|
Summary: Dependency generators for Python RPMs
|
||||||
Version: 12
|
Version: 12
|
||||||
Release: 2%{?dist}
|
Release: 3%{?dist}
|
||||||
|
|
||||||
# Originally all those files were part of RPM, so license is kept here
|
# Originally all those files were part of RPM, so license is kept here
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
@ -47,6 +47,9 @@ install -Dpm0755 -t %{buildroot}%{_rpmconfigdir} *.py
|
|||||||
%{_rpmconfigdir}/pythonbundles.py
|
%{_rpmconfigdir}/pythonbundles.py
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Feb 22 2021 Tomas Orsava <torsava@redhat.com> - 12-3
|
||||||
|
- scripts/pythondistdeps: Fix for Python 3.10
|
||||||
|
|
||||||
* Wed Feb 17 2021 Tomas Orsava <torsava@redhat.com> - 12-2
|
* Wed Feb 17 2021 Tomas Orsava <torsava@redhat.com> - 12-2
|
||||||
- scripts/pythondistdeps: Switch from using pkg_resources to importlib.metadata
|
- scripts/pythondistdeps: Switch from using pkg_resources to importlib.metadata
|
||||||
for reading the egg/dist-info metadata
|
for reading the egg/dist-info metadata
|
||||||
|
@ -53,7 +53,6 @@ class Requirement(Requirement_):
|
|||||||
class Distribution(PathDistribution):
|
class Distribution(PathDistribution):
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
super(Distribution, self).__init__(Path(path))
|
super(Distribution, self).__init__(Path(path))
|
||||||
self.name = self.metadata['Name']
|
|
||||||
self.normalized_name = normalize_name(self.name)
|
self.normalized_name = normalize_name(self.name)
|
||||||
self.legacy_normalized_name = legacy_normalize_name(self.name)
|
self.legacy_normalized_name = legacy_normalize_name(self.name)
|
||||||
self.requirements = [Requirement(r) for r in self.requires or []]
|
self.requirements = [Requirement(r) for r in self.requires or []]
|
||||||
@ -61,6 +60,15 @@ class Distribution(PathDistribution):
|
|||||||
v for k, v in self.metadata.items() if k == 'Provides-Extra']
|
v for k, v in self.metadata.items() if k == 'Provides-Extra']
|
||||||
self.py_version = self._parse_py_version(path)
|
self.py_version = self._parse_py_version(path)
|
||||||
|
|
||||||
|
# `name` is defined as a property exactly like this in Python 3.10 in the
|
||||||
|
# PathDistribution class. Due to that we can't redefine `name` as a normal
|
||||||
|
# attribute. So we copied the Python 3.10 definition here into the code so
|
||||||
|
# that it works also on previous Python/importlib_metadata versions.
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
"""Return the 'Name' metadata for the distribution package."""
|
||||||
|
return self.metadata['Name']
|
||||||
|
|
||||||
def _parse_py_version(self, path):
|
def _parse_py_version(self, path):
|
||||||
# Try to parse the Python version from the path the metadata
|
# Try to parse the Python version from the path the metadata
|
||||||
# resides at (e.g. /usr/lib/pythonX.Y/site-packages/...)
|
# resides at (e.g. /usr/lib/pythonX.Y/site-packages/...)
|
||||||
|
Loading…
Reference in New Issue
Block a user