From 5c736ea7845cf7414dc46878d33a6231db07a40e Mon Sep 17 00:00:00 2001 From: devttys0 Date: Tue, 13 Oct 2020 07:41:12 -0700 Subject: [PATCH] Added improved version.py --- .gitignore | 1 - src/binwalk/core/version.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/binwalk/core/version.py diff --git a/.gitignore b/.gitignore index 4ae789e5..af5c03a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ build dist -version.py .coverage *.extracted *.pyc diff --git a/src/binwalk/core/version.py b/src/binwalk/core/version.py new file mode 100644 index 00000000..7f98c1c2 --- /dev/null +++ b/src/binwalk/core/version.py @@ -0,0 +1,14 @@ +try: + from importlib import metadata + get_version = lambda : metadata.version("binwalk") +except ImportError: + try: + # Running on pre-3.8 Python; use importlib-metadata package + import importlib_metadata as metadata + get_version = lambda: metadata.version("binwalk") + except ImportError: + # 3rd fallback via pkg_resources + import pkg_resources + get_version = lambda : pkg_resources.get_distribution("binwalk").version + +__version__ = get_version()