Skip to content

Commit

Permalink
twisted#432 An initial attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed Apr 29, 2023
1 parent a351582 commit c933cbb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/towncrier/_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import sys

from importlib import import_module
from importlib.metadata import version as metadata_version
from importlib.metadata import PackageNotFoundError
from types import ModuleType

from incremental import Version as IncrementalVersion
Expand Down Expand Up @@ -39,8 +41,10 @@ def _get_package(package_dir: str, package: str) -> ModuleType:

def get_version(package_dir: str, package: str) -> str:
module = _get_package(package_dir, package)

version = getattr(module, "__version__", None)
try:
version = metadata_version(f"{module}")
except PackageNotFoundError:
version = getattr(module, "__version__", None)

if not version:
raise Exception("No __version__, I don't know how else to look")
Expand Down

0 comments on commit c933cbb

Please sign in to comment.