Skip to content

Commit

Permalink
feat: expose library version at googleapiclient.__version__ (#1623)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
joinsion and parthea committed Dec 13, 2021
1 parent b8de30d commit 83db1d7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
4 changes: 2 additions & 2 deletions googleapiclient/model.py
Expand Up @@ -26,12 +26,12 @@
import json
import logging
import platform
import pkg_resources
import urllib

from googleapiclient import version as googleapiclient_version
from googleapiclient.errors import HttpError

_LIBRARY_VERSION = pkg_resources.get_distribution("google-api-python-client").version
_LIBRARY_VERSION = googleapiclient_version.__version__
_PY_VERSION = platform.python_version()

LOGGER = logging.getLogger(__name__)
Expand Down
15 changes: 15 additions & 0 deletions googleapiclient/version.py
@@ -0,0 +1,15 @@
# Copyright 2021 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__ = "2.33.0"
7 changes: 6 additions & 1 deletion setup.py
Expand Up @@ -51,7 +51,12 @@
with io.open(readme_filename, encoding="utf-8") as readme_file:
readme = readme_file.read()

version = "2.33.0"
package_root = os.path.abspath(os.path.dirname(__file__))

version = {}
with open(os.path.join(package_root, "googleapiclient/version.py")) as fp:
exec(fp.read(), version)
version = version["__version__"]

setup(
name="google-api-python-client",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_json_model.py
Expand Up @@ -25,17 +25,17 @@
import io
import httplib2
import json
import pkg_resources
import platform
import unittest
import urllib

import googleapiclient.model

from googleapiclient import version as googleapiclient_version
from googleapiclient.errors import HttpError
from googleapiclient.model import JsonModel

_LIBRARY_VERSION = pkg_resources.get_distribution("google-api-python-client").version
_LIBRARY_VERSION = googleapiclient_version.__version__
CSV_TEXT_MOCK = 'column1,column2,column3\nstring1,1.2,string2'


Expand Down

0 comments on commit 83db1d7

Please sign in to comment.