Skip to content

Commit

Permalink
Preserve continuity between imports and usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-indigo committed Jul 28, 2022
1 parent c7351b2 commit 040777e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions geoalchemy2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,19 +449,20 @@ def load_spatialite(dbapi_conn, connection_record):
# back to pkg_resources for Python 3.7 support
try:
import importlib.metadata
try:
raise importlib.metadata.PackageNotFoundError
__version__ = importlib.metadata.version('GeoAlchemy2')
print('A', __version__)
except importlib.metadata.PackageNotFoundError: # pragma: no cover
pass
except ImportError:
try:
from pkg_resources import DistributionNotFound
from pkg_resources import get_distribution
except ImportError: # pragma: no cover
pass
else:
try:
__version__ = get_distribution('GeoAlchemy2').version
except DistributionNotFound: # pragma: no cover
print('B', __version__)
except DistributionNotFound: # pragma: no cover
pass
else:
try:
__version__ = importlib.metadata.version('GeoAlchemy2')
except importlib.metadata.PackageNotFoundError: # pragma: no cover
except ImportError: # pragma: no cover
pass

0 comments on commit 040777e

Please sign in to comment.