Skip to content

Commit

Permalink
fix: use version.py instead of pkg_resources.get_distribution (#94)
Browse files Browse the repository at this point in the history
* fix: use version.py instead of pkg_resources.get_distribution
  • Loading branch information
crwilcox committed Oct 6, 2020
1 parent b0b778d commit ea77534
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
5 changes: 1 addition & 4 deletions google/cloud/datastore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@
"""


from pkg_resources import get_distribution

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

from google.cloud.datastore.version import __version__
from google.cloud.datastore.batch import Batch
from google.cloud.datastore.client import Client
from google.cloud.datastore.entity import Entity
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/datastore/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from google.cloud._helpers import _LocalStack
from google.cloud._helpers import _determine_default_project as _base_default_project
from google.cloud.client import ClientWithProject
from google.cloud.datastore import __version__
from google.cloud.datastore.version import __version__
from google.cloud.datastore import helpers
from google.cloud.datastore._http import HTTPDatastoreAPI
from google.cloud.datastore.batch import Batch
Expand Down
15 changes: 15 additions & 0 deletions google/cloud/datastore/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "1.15.1"
12 changes: 8 additions & 4 deletions google/cloud/datastore_admin_v1/gapic/datastore_admin_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""Accesses the google.datastore.admin.v1 DatastoreAdmin API."""

import functools
import pkg_resources
import os
import warnings

from google.oauth2 import service_account
Expand All @@ -43,10 +43,14 @@
from google.longrunning import operations_pb2
from google.protobuf import empty_pb2

# To avoid importing datastore into admin (which would result in a
# circular dependency), We exec to get the version via a dict.
dir_path = os.path.abspath(os.path.dirname(__file__))
version = {}
with open(os.path.join(dir_path, "../../datastore/version.py")) as fp:
exec(fp.read(), version)

_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution(
"google-cloud-datastore",
).version
_GAPIC_LIBRARY_VERSION = version["__version__"]


class DatastoreAdminClient(object):
Expand Down
5 changes: 2 additions & 3 deletions google/cloud/datastore_v1/gapic/datastore_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@
from google.cloud.datastore_v1.proto import datastore_pb2_grpc
from google.cloud.datastore_v1.proto import entity_pb2
from google.cloud.datastore_v1.proto import query_pb2
from google.cloud.datastore.version import __version__


_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution(
"google-cloud-datastore",
).version
_GAPIC_LIBRARY_VERSION = __version__


class DatastoreClient(object):
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@

name = "google-cloud-datastore"
description = "Google Cloud Datastore API client library"
version = "1.15.1"
version = {}
with open("google/cloud/datastore/version.py") as fp:
exec(fp.read(), version)
version = version["__version__"]

# Should be one of:
# 'Development Status :: 3 - Alpha'
# 'Development Status :: 4 - Beta'
Expand Down

0 comments on commit ea77534

Please sign in to comment.