From d1837b662f7c6d667a90c999286032ec8f087552 Mon Sep 17 00:00:00 2001 From: Chris Wilcox Date: Tue, 6 Oct 2020 12:39:52 -0700 Subject: [PATCH 1/5] fix: harden version data gathering against DistributionNotFound --- google/cloud/storage/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/google/cloud/storage/__init__.py b/google/cloud/storage/__init__.py index 2a9629dfb..afa13ebee 100644 --- a/google/cloud/storage/__init__.py +++ b/google/cloud/storage/__init__.py @@ -31,10 +31,11 @@ machine). """ - -from pkg_resources import get_distribution - -__version__ = get_distribution("google-cloud-storage").version +import pkg_resources +try: + __version__ = pkg_resources.get_distribution("google-cloud-storage").version +except pkg_resources.DistributionNotFound: + __version__ = None from google.cloud.storage.batch import Batch from google.cloud.storage.blob import Blob From 798e2272ec35dce15cdd5db8f0926feea6de27f6 Mon Sep 17 00:00:00 2001 From: Chris Wilcox Date: Tue, 6 Oct 2020 12:56:59 -0700 Subject: [PATCH 2/5] fix: lint --- google/cloud/storage/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/google/cloud/storage/__init__.py b/google/cloud/storage/__init__.py index afa13ebee..74cc66ee8 100644 --- a/google/cloud/storage/__init__.py +++ b/google/cloud/storage/__init__.py @@ -32,6 +32,7 @@ """ import pkg_resources + try: __version__ = pkg_resources.get_distribution("google-cloud-storage").version except pkg_resources.DistributionNotFound: From 4e7315595f181744c6787163b8a756da2e13b3fa Mon Sep 17 00:00:00 2001 From: Chris Wilcox Date: Tue, 6 Oct 2020 13:13:23 -0700 Subject: [PATCH 3/5] fix: create version.py for package versioning --- google/cloud/storage/__init__.py | 8 +------- setup.py | 6 +++++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/google/cloud/storage/__init__.py b/google/cloud/storage/__init__.py index 74cc66ee8..b05efab8c 100644 --- a/google/cloud/storage/__init__.py +++ b/google/cloud/storage/__init__.py @@ -31,13 +31,7 @@ machine). """ -import pkg_resources - -try: - __version__ = pkg_resources.get_distribution("google-cloud-storage").version -except pkg_resources.DistributionNotFound: - __version__ = None - +from google.cloud.storage.version import __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/setup.py b/setup.py index 4c38e9474..8a848bcfa 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,6 @@ name = "google-cloud-storage" description = "Google Cloud Storage API client library" -version = "1.31.2" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta' @@ -41,6 +40,11 @@ package_root = os.path.abspath(os.path.dirname(__file__)) +version = {} +with open(os.path.join(package_root, "google/cloud/storage/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() From b426197c1dfb80a7de4f32b5b5aa7b08e503181b Mon Sep 17 00:00:00 2001 From: Chris Wilcox Date: Tue, 6 Oct 2020 13:36:17 -0700 Subject: [PATCH 4/5] fix: commit missing file --- google/cloud/storage/version.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 google/cloud/storage/version.py diff --git a/google/cloud/storage/version.py b/google/cloud/storage/version.py new file mode 100644 index 000000000..692275969 --- /dev/null +++ b/google/cloud/storage/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.31.2" \ No newline at end of file From a05e164804b5adc68fa4ba8ffac3028dfd64cf41 Mon Sep 17 00:00:00 2001 From: Christopher Wilcox Date: Tue, 6 Oct 2020 13:54:40 -0700 Subject: [PATCH 5/5] fix: lint --- google/cloud/storage/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google/cloud/storage/version.py b/google/cloud/storage/version.py index 692275969..3dc5937fc 100644 --- a/google/cloud/storage/version.py +++ b/google/cloud/storage/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "1.31.2" \ No newline at end of file +__version__ = "1.31.2"