diff --git a/lambda_local/__init__.py b/lambda_local/__init__.py index e5899ab..d024373 100644 --- a/lambda_local/__init__.py +++ b/lambda_local/__init__.py @@ -7,11 +7,18 @@ from __future__ import print_function import argparse -import pkg_resources -from .main import run +# Get the version of python-lambda-local +try: + from importlib.metadata import version as get_version + __version__ = get_version("python-lambda-local") + +# If importlib.metadata is not available, use pkg_resources (older versions of Python) +except ImportError: + from pkg_resources import require + __version__ = require("python-lambda-local")[0].version -__version__ = pkg_resources.require("python-lambda-local")[0].version +from .main import run def main():