Skip to content

Commit

Permalink
Merge pull request #244 from acsone/fix-setup.py-old-python-sbi
Browse files Browse the repository at this point in the history
Fix issue when running setup.py on python<3.8
  • Loading branch information
pedrobaeza authored Sep 22, 2021
2 parents 871058a + 057cdbd commit 5a572ef
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions openupgradelib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5a572ef

Please sign in to comment.