diff --git a/pipeline/__init__.py b/pipeline/__init__.py index 44516a8a..8c175192 100644 --- a/pipeline/__init__.py +++ b/pipeline/__init__.py @@ -1,20 +1,21 @@ PackageNotFoundError = None +DistributionNotFound = None try: from importlib.metadata import PackageNotFoundError from importlib.metadata import version as get_version -except ImportError: - get_version = None -try: - from pkg_resources import DistributionNotFound as PackageNotFoundError - from pkg_resources import get_distribution - - - def get_version(x): - return get_distribution(x).version except ImportError: get_version = None PackageNotFoundError = None - get_distribution = None +if get_version is None: + try: + from pkg_resources import DistributionNotFound, get_distribution + + def get_version(x): + return get_distribution(x).version + except ImportError: + get_version = None + DistributionNotFound = None + get_distribution = None __version__ = None if get_version is not None: @@ -22,3 +23,5 @@ def get_version(x): __version__ = get_version("django-pipeline") except PackageNotFoundError: pass + except DistributionNotFound: + pass