Skip to content

Commit c92c8ad

Browse files
aboelhamdcarlzogh
andauthored
Remove importlib.metadata dependency (#55)
Co-authored-by: Carl Zogheib <[email protected]>
1 parent 56eb1ca commit c92c8ad

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

awslambdaric/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""
2+
Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
"""
4+
5+
__version__ = "1.2.2"

awslambdaric/lambda_runtime_client.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,14 @@
55
import http
66
import http.client
77
import sys
8-
9-
try:
10-
from importlib import metadata
11-
except ImportError:
12-
# Running on pre-3.8 Python; use importlib-metadata package
13-
import importlib_metadata as metadata
8+
from awslambdaric import __version__
149

1510

1611
def _user_agent():
1712
py_version = (
1813
f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
1914
)
20-
try:
21-
pkg_version = metadata.version("awslambdaric")
22-
except:
23-
pkg_version = "unknown"
15+
pkg_version = __version__
2416
return f"aws-lambda-python/{py_version}-{pkg_version}"
2517

2618

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import platform
88
from subprocess import check_call, check_output
99
from setuptools import Extension, find_packages, setup
10+
from awslambdaric import __version__
1011

1112

1213
def get_curl_extra_linker_flags():
@@ -68,7 +69,7 @@ def read_requirements(req="base.txt"):
6869

6970
setup(
7071
name="awslambdaric",
71-
version="1.2.1",
72+
version=__version__,
7273
author="Amazon Web Services",
7374
description="AWS Lambda Runtime Interface Client for Python",
7475
long_description=read("README.md"),

tests/test_lambda_runtime_client.py

+6
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
import http.client
77
import unittest.mock
88
from unittest.mock import MagicMock, patch
9+
from awslambdaric import __version__
10+
911

1012
from awslambdaric.lambda_runtime_client import (
1113
LambdaRuntimeClient,
1214
LambdaRuntimeClientError,
1315
InvocationRequest,
16+
_user_agent,
1417
)
1518

1619

@@ -205,6 +208,9 @@ def test_invalid_addr(self):
205208
runtime_client = LambdaRuntimeClient("::::")
206209
runtime_client.post_init_error("error")
207210

211+
def test_lambdaric_version(self):
212+
self.assertTrue(_user_agent().endswith(__version__))
213+
208214

209215
class TestLambdaRuntimeClientError(unittest.TestCase):
210216
def test_constructor(self):

0 commit comments

Comments
 (0)