From 057cdbdb0cd3edb18201ca090f57908681512c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Wed, 22 Sep 2021 17:03:37 +0200 Subject: [PATCH] Fix issue when running setup.py on python<3.8 --- openupgradelib/__init__.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/openupgradelib/__init__.py b/openupgradelib/__init__.py index 43459b9d..3e3214c8 100755 --- a/openupgradelib/__init__.py +++ b/openupgradelib/__init__.py @@ -8,13 +8,17 @@ __license__ = "AGPL-3" -if sys.version_info >= (3, 8): - from importlib.metadata import version, PackageNotFoundError -else: - from importlib_metadata import version, PackageNotFoundError - try: - __version__ = version("openupgradelib") -except PackageNotFoundError: - # package is not installed + if sys.version_info >= (3, 8): + from importlib.metadata import version, PackageNotFoundError + else: + from importlib_metadata import version, PackageNotFoundError +except ImportError: + # this happens when setup.py imports openupgradelib pass +else: + try: + __version__ = version("openupgradelib") + except PackageNotFoundError: + # package is not installed + pass