Skip to content

Commit

Permalink
Merge pull request #1193 from stefanor/keyring-optional-cli
Browse files Browse the repository at this point in the history
Handle missing optional dependencies in dep_versions()
  • Loading branch information
sigmavirus24 authored Dec 6, 2024
2 parents 55854b7 + d96eb5d commit 626423a
Showing 1 changed file with 11 additions and 2 deletions.
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

0 comments on commit 626423a

Please sign in to comment.