Skip to content

Commit 523dbd0

Browse files
authored
fix: remove dependency on pkg_resources (#361)
Fixes #360 🦕
1 parent caba5f2 commit 523dbd0

File tree

3 files changed

+9
-23
lines changed

3 files changed

+9
-23
lines changed

google/api_core/client_info.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import platform
2222
from typing import Union
2323

24-
import pkg_resources
25-
2624
from google.api_core import version as api_core_version
2725

2826
_PY_VERSION = platform.python_version()
@@ -31,8 +29,10 @@
3129
_GRPC_VERSION: Union[str, None]
3230

3331
try:
34-
_GRPC_VERSION = pkg_resources.get_distribution("grpcio").version
35-
except pkg_resources.DistributionNotFound: # pragma: NO COVER
32+
import grpc
33+
34+
_GRPC_VERSION = grpc.__version__
35+
except ImportError: # pragma: NO COVER
3636
_GRPC_VERSION = None
3737

3838

google/api_core/grpc_helpers.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import functools
1919

2020
import grpc
21-
import pkg_resources
2221

2322
from google.api_core import exceptions
2423
import google.auth
@@ -33,14 +32,6 @@
3332
except ImportError:
3433
HAS_GRPC_GCP = False
3534

36-
try:
37-
# google.auth.__version__ was added in 1.26.0
38-
_GOOGLE_AUTH_VERSION = google.auth.__version__
39-
except AttributeError:
40-
try: # try pkg_resources if it is available
41-
_GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
42-
except pkg_resources.DistributionNotFound: # pragma: NO COVER
43-
_GOOGLE_AUTH_VERSION = None
4435

4536
# The list of gRPC Callable interfaces that return iterators.
4637
_STREAM_WRAP_CLASSES = (grpc.UnaryStreamMultiCallable, grpc.StreamStreamMultiCallable)

google/api_core/operations_v1/transports/base.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,21 @@
1616
import abc
1717
from typing import Awaitable, Callable, Optional, Sequence, Union
1818

19-
import pkg_resources
20-
2119
import google.api_core # type: ignore
2220
from google.api_core import exceptions as core_exceptions # type: ignore
2321
from google.api_core import gapic_v1 # type: ignore
2422
from google.api_core import retry as retries # type: ignore
23+
from google.api_core import version
2524
import google.auth # type: ignore
2625
from google.auth import credentials as ga_credentials # type: ignore
2726
from google.longrunning import operations_pb2
2827
from google.oauth2 import service_account # type: ignore
2928
from google.protobuf import empty_pb2 # type: ignore
3029

31-
try:
32-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
33-
gapic_version=pkg_resources.get_distribution(
34-
"google.api_core.operations_v1",
35-
).version,
36-
)
37-
except pkg_resources.DistributionNotFound:
38-
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
30+
31+
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
32+
gapic_version=version.__version__,
33+
)
3934

4035

4136
class OperationsTransport(abc.ABC):

0 commit comments

Comments
 (0)