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

Handle missing optional dependencies in dep_versions() #1193

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions twine/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,24 @@ def configure_output() -> None:

def list_dependencies_and_versions() -> List[Tuple[str, str]]:
deps = [
"keyring",
"keyring", # optional for non-desktop use
"pkginfo",
"requests",
"requests-toolbelt",
"urllib3",
]
if sys.version_info < (3, 10):
deps.append("importlib-metadata")
return [(dep, importlib_metadata.version(dep)) for dep in deps]

result: List[Tuple[str, str]] = []
for dep in deps:
try:
version = importlib_metadata.version(dep)
except importlib_metadata.PackageNotFoundError:
version = "NOT INSTALLED"
result.append((dep, version))

return result


def dep_versions() -> str:
Expand Down
Loading