Skip to content

Commit b76fc05

Browse files
committed
Make the use of pkg_resources optional
As it's only to enhance the logging, we'll just log the version of argo_ams_library if the module is available. pkg_resources is distributed with setuptools, which is commonly installed, but we don't want to add any dependencies for this "nice to have" functionality.
1 parent cb4358e commit b76fc05

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ssm/ssm2.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
"""
1616
from __future__ import print_function
1717

18-
import pkg_resources
19-
2018
from ssm import crypto
2119
from ssm.message_directory import MessageDirectory
2220

@@ -28,6 +26,13 @@
2826
QueueSimple = None
2927
Queue = None
3028

29+
try:
30+
import pkg_resources
31+
except ImportError:
32+
# pkg_resources is distributed with setuptools, but as it's only used to enhance
33+
# the logging, it can be optional.
34+
pkg_resources = None
35+
3136
import stomp
3237
from stomp.exception import ConnectFailedException
3338

@@ -551,7 +556,9 @@ def handle_connect(self):
551556
connect to each in turn until successful.
552557
"""
553558
if self._protocol == Ssm2.AMS_MESSAGING:
554-
log.info("Using AMS version %s", pkg_resources.get_distribution('argo_ams_library').version)
559+
if pkg_resources is not None:
560+
# We only log the version if pkg_resources is available.
561+
log.info("Using AMS version %s", pkg_resources.get_distribution('argo_ams_library').version)
555562

556563
log.info("Will connect to %s", self._brokers[0])
557564

0 commit comments

Comments
 (0)