Skip to content

Commit 76d43b3

Browse files
committed
Add __version__ attribute to boltons package
Uses importlib.metadata to read the version from the installed package metadata, falling back to "unknown" when running from a source checkout without installing. This allows users to do: import boltons print(boltons.__version__)
1 parent 49f381e commit 76d43b3

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

boltons/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from importlib.metadata import version, PackageNotFoundError
2+
3+
try:
4+
__version__ = version("boltons")
5+
except PackageNotFoundError:
6+
# Package is not installed (e.g. running from source checkout)
7+
__version__ = "unknown"

0 commit comments

Comments
 (0)