Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: harden version data gathering against DistributionNotFound #150

Merged
merged 1 commit into from Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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