Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix show config when package names are not canonical #2103

Merged
merged 1 commit into from Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog/2103.bugfix.rst
@@ -0,0 +1 @@
Fix show config when the package names are not in canonical form - by :user:`gaborbernat`.
8 changes: 3 additions & 5 deletions src/tox/session/commands/show_config.py
Expand Up @@ -2,7 +2,6 @@
from collections import OrderedDict

from packaging.requirements import Requirement
from packaging.utils import canonicalize_name
from six import StringIO
from six.moves import configparser

Expand Down Expand Up @@ -65,16 +64,15 @@ def version_info(parser):
while to_visit:
current = to_visit.pop()
current_dist = importlib_metadata.distribution(current)
current_name = canonicalize_name(current_dist.metadata["name"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, I was pretty sure I added the canonicalize name because there were duplicates in the output

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, not sure what happened here but canonicalize name now makes it break... do you still have your use case to validate?

current_name = current_dist.metadata["name"]
versions[current_name] = current_dist.version
if current_dist.requires is not None:
for require in current_dist.requires:
pkg = Requirement(require)
pkg_name = canonicalize_name(pkg.name)
if (
pkg.marker is None or pkg.marker.evaluate({"extra": ""})
) and pkg_name not in versions:
to_visit.add(pkg_name)
) and pkg.name not in versions:
to_visit.add(pkg.name)
set_section(parser, "tox:versions", versions)


Expand Down