Resolver does not handle '-', '.', '_' characters in package name
Setuptools package naming includes agnosticism of the use of -
,_
, and .
in package names.
PyPi will also cleanly handle replacement of these characters in package names, resolving package_name
to package.name
if that is what is specified for the distribution.
Resolving metadata for a given imported package name which does not match the distribution name exactly fails with PackageNotFoundError
.
I believe importlib_metadata should properly resolve names regardless of the use of -
,_
, and .
in order to work with the naming conventions defined by PyPA.
Python 3.7.3 (default, May 11 2019, 00:38:04)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import importlib_metadata
In [2]: importlib_metadata.metadata('widgetastic_patternfly')
---------------------------------------------------------------------------
PackageNotFoundError Traceback (most recent call last)
<ipython-input-2-6076e0b12a08> in <module>
----> 1 importlib_metadata.metadata('widgetastic_patternfly')
~/[redacted]/lib64/python3.7/site-packages/importlib_metadata/__init__.py in metadata(package)
433 :return: An email.Message containing the parsed metadata.
434 """
--> 435 return Distribution.from_name(package).metadata
436
437
~/[redacted]/lib64/python3.7/site-packages/importlib_metadata/__init__.py in from_name(cls, name)
182 return dist
183 else:
--> 184 raise PackageNotFoundError(name)
185
186 @classmethod
PackageNotFoundError: widgetastic_patternfly
In [3]: importlib_metadata.metadata('widgetastic.patternfly')
Out[3]: <email.message.Message at 0x7f064c0464a8>
Edited by Mike Shriver