Skip to content

Commit 2ea35e9

Browse files
committed
fix: avoid using 'pkg_resources' to determine version
Closes #39.
1 parent 23894f1 commit 2ea35e9

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

google/cloud/_http.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@
1919
import platform
2020
import warnings
2121

22-
from pkg_resources import get_distribution
2322
from six.moves import collections_abc
2423
from six.moves.urllib.parse import urlencode
2524

2625
from google.api_core.client_info import ClientInfo
2726
from google.cloud import exceptions
27+
from google.cloud import version
2828

2929

3030
API_BASE_URL = "https://www.googleapis.com"
3131
"""The base of the API call URL."""
3232

3333
DEFAULT_USER_AGENT = "gcloud-python/{0}".format(
34-
get_distribution("google-cloud-core").version
34+
version.__version__
3535
)
3636
"""The user agent for google-cloud-python requests."""
3737

google/cloud/version.py

+15
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.4.2"

setup.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
name = "google-cloud-core"
2424
description = "Google Cloud API client core library"
25-
version = "1.4.2"
2625
# Should be one of:
2726
# 'Development Status :: 3 - Alpha'
2827
# 'Development Status :: 4 - Beta'
@@ -36,6 +35,11 @@
3635

3736
package_root = os.path.abspath(os.path.dirname(__file__))
3837

38+
version = {}
39+
with open(os.path.join(package_root, "google/cloud/version.py")) as fp:
40+
exec(fp.read(), version)
41+
version = version['__version__']
42+
3943
readme_filename = os.path.join(package_root, "README.rst")
4044
with io.open(readme_filename, encoding="utf-8") as readme_file:
4145
readme = readme_file.read()

0 commit comments

Comments
 (0)