Distribution lookup fails with dashes in the name
Similar to #20 (closed), I've found that if a package has dashes in the name, the distribution lookup will fail with a PackageNotFoundError
.
>>> import importlib_metadata
>>> importlib_metadata.version('elastic2-doc-manager')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jaraco/code/yg/public/elastic2-doc-manager/.tox/python/lib/python3.7/site-packages/importlib_metadata/api.py", line 105, in version
return distribution(package).version
File "/Users/jaraco/code/yg/public/elastic2-doc-manager/.tox/python/lib/python3.7/site-packages/importlib_metadata/api.py", line 86, in distribution
return Distribution.from_name(package)
File "/Users/jaraco/code/yg/public/elastic2-doc-manager/.tox/python/lib/python3.7/site-packages/importlib_metadata/api.py", line 52, in from_name
raise PackageNotFoundError(name)
importlib_metadata.api.PackageNotFoundError: elastic2-doc-manager
>>> ^D
elastic2-doc-manager feature/auto-version $ ls -d .tox/python/lib/python3.7/site-packages/elastic*.dist-info
.tox/python/lib/python3.7/site-packages/elastic2_doc_manager-0.4.1.dev4+g5558283.dist-info
I suspect that to support resolving version numbers from filenames and disambiguating a dash in the name from the dash that separates the name from the version, some tool is "normalizing" dashes to underscores... so to look up the metadata for a distribution, the name needs to be normalized this way.
I might have thought it would go the other way, because pypi normalizes the other way.