close
Skip to content

Distribution lookup fails with dashes in the name #21

Description

@jaraco

In GitLab by @jaraco on Nov 4, 2018, 09:36

Similar to #20, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions