Skip to content

Commit 1fb06ee

Browse files
committed
Replace deprecated pkg_resources with importlib.metadata
Fixes deprecation warning about pkg_resources being slated for removal. Uses importlib.metadata (Python 3.8+) with fallback to importlib_metadata for older Python versions to maintain backward compatibility.
1 parent 3ebf043 commit 1fb06ee

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

blimpy/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818
except:
1919
print("Warning: At least one utility could not be imported!")
2020

21-
from pkg_resources import get_distribution, DistributionNotFound
21+
try:
22+
from importlib.metadata import version, PackageNotFoundError
23+
except ImportError:
24+
# Fallback for Python < 3.8
25+
from importlib_metadata import version, PackageNotFoundError
2226

2327
try:
24-
__version__ = get_distribution('blimpy').version
25-
except DistributionNotFound:
28+
__version__ = version('blimpy')
29+
except PackageNotFoundError:
2630
__version__ = '0.0.0 - please install via pip/setup.py'

0 commit comments

Comments
 (0)