From 568578d33f71117564ee9212daad72d4e2b739a6 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Tue, 6 Oct 2020 14:21:15 -0400 Subject: [PATCH] fix: avoid using 'pkg_resources' to determine version (#40) Closes #39. --- google/cloud/_http.py | 4 ++-- google/cloud/version.py | 15 +++++++++++++++ setup.py | 6 +++++- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 google/cloud/version.py diff --git a/google/cloud/_http.py b/google/cloud/_http.py index 74539a5..8062622 100644 --- a/google/cloud/_http.py +++ b/google/cloud/_http.py @@ -19,19 +19,19 @@ import platform import warnings -from pkg_resources import get_distribution from six.moves import collections_abc from six.moves.urllib.parse import urlencode from google.api_core.client_info import ClientInfo from google.cloud import exceptions +from google.cloud import version API_BASE_URL = "https://www.googleapis.com" """The base of the API call URL.""" DEFAULT_USER_AGENT = "gcloud-python/{0}".format( - get_distribution("google-cloud-core").version + version.__version__ ) """The user agent for google-cloud-python requests.""" diff --git a/google/cloud/version.py b/google/cloud/version.py new file mode 100644 index 0000000..6c9b5b8 --- /dev/null +++ b/google/cloud/version.py @@ -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.4.2" diff --git a/setup.py b/setup.py index 17e6a30..8db7c0f 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,6 @@ name = "google-cloud-core" description = "Google Cloud API client core library" -version = "1.4.2" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta' @@ -36,6 +35,11 @@ package_root = os.path.abspath(os.path.dirname(__file__)) +version = {} +with open(os.path.join(package_root, "google/cloud/version.py")) as fp: + exec(fp.read(), version) +version = version['__version__'] + readme_filename = os.path.join(package_root, "README.rst") with io.open(readme_filename, encoding="utf-8") as readme_file: readme = readme_file.read()