Skip to content

Commit

Permalink
get package version using importlib
Browse files Browse the repository at this point in the history
  • Loading branch information
frank1010111 authored and jokva committed Nov 27, 2024
1 parent eca00a5 commit e5bf243
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions wellpathpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import sys
if sys.version_info >= (3, 8):
from importlib import metadata
else:
import importlib_metadata as metadata

try:
import pkg_resources
__version__ = pkg_resources.get_distribution(__name__).version
except pkg_resources.DistributionNotFound:
__version__ = metadata.version(__name__)
except: # PackageNotFoundError
# Don't hard crash when the the version cannot be looked up from the
# metadata, probably because the tests are running from the source dir and
# the module has not been packaged yet.
pass

__all__ = [
Expand Down

0 comments on commit e5bf243

Please sign in to comment.