From 5a9f079bea98e3ea415df3fa4fbd813cc268b1f2 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Tue, 21 Feb 2017 22:00:14 -0800 Subject: [PATCH] Using __version__ in datastore and storage. --- datastore/google/cloud/datastore/__init__.py | 3 +++ datastore/google/cloud/datastore/_http.py | 7 +++---- storage/google/cloud/storage/__init__.py | 4 ++++ storage/google/cloud/storage/_http.py | 7 +++---- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/datastore/google/cloud/datastore/__init__.py b/datastore/google/cloud/datastore/__init__.py index 89e0eaaa31ea..e09b2101e9ca 100644 --- a/datastore/google/cloud/datastore/__init__.py +++ b/datastore/google/cloud/datastore/__init__.py @@ -54,6 +54,9 @@ """ +from pkg_resources import get_distribution +__version__ = get_distribution('google-cloud-datastore').version + from google.cloud.datastore.batch import Batch from google.cloud.datastore.client import Client from google.cloud.datastore.entity import Entity diff --git a/datastore/google/cloud/datastore/_http.py b/datastore/google/cloud/datastore/_http.py index edef8a9f30a4..a4c0a3f8c906 100644 --- a/datastore/google/cloud/datastore/_http.py +++ b/datastore/google/cloud/datastore/_http.py @@ -15,7 +15,6 @@ """Connections to Google Cloud Datastore API servers.""" import os -from pkg_resources import get_distribution from google.rpc import status_pb2 @@ -24,6 +23,8 @@ from google.cloud.environment_vars import GCD_HOST from google.cloud import exceptions from google.cloud.grpc.datastore.v1 import datastore_pb2 as _datastore_pb2 + +from google.cloud.datastore import __version__ try: from google.cloud.datastore._gax import _DatastoreAPIOverGRPC _HAVE_GRPC = True @@ -37,9 +38,7 @@ _DISABLE_GRPC = os.getenv(DISABLE_GRPC, False) _USE_GRPC = _HAVE_GRPC and not _DISABLE_GRPC -_DATASTORE_DIST = get_distribution('google-cloud-datastore') -_CLIENT_INFO = connection_module.CLIENT_INFO_TEMPLATE.format( - _DATASTORE_DIST.version) +_CLIENT_INFO = connection_module.CLIENT_INFO_TEMPLATE.format(__version__) class _DatastoreAPIOverHttp(object): diff --git a/storage/google/cloud/storage/__init__.py b/storage/google/cloud/storage/__init__.py index 10db1a1ce543..3303be5bdd7e 100644 --- a/storage/google/cloud/storage/__init__.py +++ b/storage/google/cloud/storage/__init__.py @@ -30,6 +30,10 @@ machine). """ + +from pkg_resources import get_distribution +__version__ = get_distribution('google-cloud-storage').version + from google.cloud.storage.batch import Batch from google.cloud.storage.blob import Blob from google.cloud.storage.bucket import Bucket diff --git a/storage/google/cloud/storage/_http.py b/storage/google/cloud/storage/_http.py index a1f5f9497dd7..b23096db2253 100644 --- a/storage/google/cloud/storage/_http.py +++ b/storage/google/cloud/storage/_http.py @@ -14,13 +14,12 @@ """Create / interact with Google Cloud Storage connections.""" -from pkg_resources import get_distribution - from google.cloud import _http +from google.cloud.storage import __version__ + -_STORAGE_DIST = get_distribution('google-cloud-storage') -_CLIENT_INFO = _http.CLIENT_INFO_TEMPLATE.format(_STORAGE_DIST.version) +_CLIENT_INFO = _http.CLIENT_INFO_TEMPLATE.format(__version__) class Connection(_http.JSONConnection):