Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ea77534

Browse filesBrowse files
authored
fix: use version.py instead of pkg_resources.get_distribution (#94)
* fix: use version.py instead of pkg_resources.get_distribution
1 parent b0b778d commit ea77534
Copy full SHA for ea77534

File tree

Expand file treeCollapse file tree

6 files changed

+32
-13
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+32
-13
lines changed

‎google/cloud/datastore/__init__.py

Copy file name to clipboardExpand all lines: google/cloud/datastore/__init__.py
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@
5555
"""
5656

5757

58-
from pkg_resources import get_distribution
59-
60-
__version__ = get_distribution("google-cloud-datastore").version
61-
58+
from google.cloud.datastore.version import __version__
6259
from google.cloud.datastore.batch import Batch
6360
from google.cloud.datastore.client import Client
6461
from google.cloud.datastore.entity import Entity

‎google/cloud/datastore/client.py

Copy file name to clipboardExpand all lines: google/cloud/datastore/client.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from google.cloud._helpers import _LocalStack
2222
from google.cloud._helpers import _determine_default_project as _base_default_project
2323
from google.cloud.client import ClientWithProject
24-
from google.cloud.datastore import __version__
24+
from google.cloud.datastore.version import __version__
2525
from google.cloud.datastore import helpers
2626
from google.cloud.datastore._http import HTTPDatastoreAPI
2727
from google.cloud.datastore.batch import Batch

‎google/cloud/datastore/version.py

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
__version__ = "1.15.1"

‎google/cloud/datastore_admin_v1/gapic/datastore_admin_client.py

Copy file name to clipboardExpand all lines: google/cloud/datastore_admin_v1/gapic/datastore_admin_client.py
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"""Accesses the google.datastore.admin.v1 DatastoreAdmin API."""
1818

1919
import functools
20-
import pkg_resources
20+
import os
2121
import warnings
2222

2323
from google.oauth2 import service_account
@@ -43,10 +43,14 @@
4343
from google.longrunning import operations_pb2
4444
from google.protobuf import empty_pb2
4545

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

47-
_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution(
48-
"google-cloud-datastore",
49-
).version
53+
_GAPIC_LIBRARY_VERSION = version["__version__"]
5054

5155

5256
class DatastoreAdminClient(object):

‎google/cloud/datastore_v1/gapic/datastore_client.py

Copy file name to clipboardExpand all lines: google/cloud/datastore_v1/gapic/datastore_client.py
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@
3636
from google.cloud.datastore_v1.proto import datastore_pb2_grpc
3737
from google.cloud.datastore_v1.proto import entity_pb2
3838
from google.cloud.datastore_v1.proto import query_pb2
39+
from google.cloud.datastore.version import __version__
3940

4041

41-
_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution(
42-
"google-cloud-datastore",
43-
).version
42+
_GAPIC_LIBRARY_VERSION = __version__
4443

4544

4645
class DatastoreClient(object):

‎setup.py

Copy file name to clipboardExpand all lines: setup.py
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222

2323
name = "google-cloud-datastore"
2424
description = "Google Cloud Datastore API client library"
25-
version = "1.15.1"
25+
version = {}
26+
with open("google/cloud/datastore/version.py") as fp:
27+
exec(fp.read(), version)
28+
version = version["__version__"]
29+
2630
# Should be one of:
2731
# 'Development Status :: 3 - Alpha'
2832
# 'Development Status :: 4 - Beta'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.