Skip to content

Commit e927e4c

Browse files
committed
Remove usage of deprecated pkg_resource in favor of importlib.metadata
1 parent e4dff95 commit e927e4c

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

elasticapm/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2929
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3030
import sys
31+
import importlib.metadata
3132

3233
from elasticapm.base import Client, get_client # noqa: F401
3334
from elasticapm.conf import setup_logging # noqa: F401
@@ -54,10 +55,7 @@
5455
_activation_method = None
5556

5657
try:
57-
try:
58-
VERSION = __import__("importlib.metadata").metadata.version("elastic-apm")
59-
except ImportError:
60-
VERSION = __import__("pkg_resources").get_distribution("elastic-apm").version
58+
VERSION = importlib.metadata.version("elastic-apm")
6159
except Exception:
6260
VERSION = "unknown"
6361

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@
4242

4343
import ast
4444
import codecs
45+
import importlib.metadata
4546
import os
4647

47-
import pkg_resources
4848
from setuptools import setup
4949

50-
pkg_resources.require("setuptools>=39.2")
50+
importlib.metadata.requires("setuptools>=39.2")
5151

5252

5353
def get_version():

0 commit comments

Comments
 (0)