[Rpm-maint] [rpm-software-management/rpm] pythondistdeps: Switch to importlib.metadata (#1317)

Miro Hrončok notifications at github.com
Thu Sep 24 11:22:09 UTC 2020


@hroncok commented on this pull request.



>  from warnings import warn
 
+try:
+    from importlib.metadata import PathDistribution
+except ImportError:
+    from importlib_metadata import PathDistribution
+
+try:
+    from pathlib import Path
+except ImportError:
+    from pathlib2 import Path
+
+
+class Req(Requirement):
+    @property
+    def key(self):
+        return self.name.lower().replace('_', '-')

That really depends on `self.name` value. I don't see that from the code here.

In pkg_resources, key is based on `self.project_name` and that [is set to](https://github.com/pypa/setuptools/blob/73e379cc55ac1e9ec63c4ac30b75ecc82418f513/pkg_resources/__init__.py#L2564) `safe_name(project_name)`.

In packaging, I believe `self.name` is not pre-processed. See:

```pycon
>>> import pkg_resources
>>> pkg_resources.safe_name("Tree-_-FALLING.Down").lower()
'tree-falling.down'
>>> from packaging.requirements import Requirement
>>> Requirement("Tree-_-FALLING.Down").name.lower().replace('_', '-')
'tree---falling.down'
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/1317#discussion_r494234076
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20200924/c3950fd3/attachment-0001.html>


More information about the Rpm-maint mailing list