Skip to content

Commit

Permalink
fix: harden version data gathering against DistributionNotFound (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
crwilcox committed Oct 6, 2020
1 parent 34384e4 commit c815421
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
8 changes: 6 additions & 2 deletions google/cloud/bigtable/__init__.py
Expand Up @@ -15,9 +15,13 @@
"""Google Cloud Bigtable API package."""


from pkg_resources import get_distribution
import pkg_resources

try:
__version__ = pkg_resources.get_distribution("google-cloud-bigtable").version
except pkg_resources.DistributionNotFound:
__version__ = None

__version__ = get_distribution("google-cloud-bigtable").version

from google.cloud.bigtable.client import Client

Expand Down
Expand Up @@ -49,9 +49,12 @@
from google.protobuf import field_mask_pb2


_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution(
"google-cloud-bigtable",
).version
try:
_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution(
"google-cloud-bigtable"
).version
except pkg_resources.DistributionNotFound:
_GAPIC_LIBRARY_VERSION = None


class BigtableInstanceAdminClient(object):
Expand Down
Expand Up @@ -54,9 +54,14 @@
from google.protobuf import field_mask_pb2


_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution(
"google-cloud-bigtable",
).version
import pkg_resources

try:
_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution(
"google-cloud-bigtable"
).version
except pkg_resources.DistributionNotFound:
_GAPIC_LIBRARY_VERSION = None


class BigtableTableAdminClient(object):
Expand Down
9 changes: 6 additions & 3 deletions google/cloud/bigtable_v2/gapic/bigtable_client.py
Expand Up @@ -36,9 +36,12 @@
from google.cloud.bigtable_v2.proto import data_pb2


_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution(
"google-cloud-bigtable",
).version
try:
_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution(
"google-cloud-bigtable"
).version
except pkg_resources.DistributionNotFound:
_GAPIC_LIBRARY_VERSION = None


class BigtableClient(object):
Expand Down

0 comments on commit c815421

Please sign in to comment.