Skip to content

fix: Use version.py instead of pkg_resources on v1 #1671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions googleapiclient/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
import json
import logging
import platform
import pkg_resources

from six.moves.urllib.parse import urlencode

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2022 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.12.0"
6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
readme = readme_file.read()

version = "1.12.10"
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
import copy
import json
import os
import pkg_resources
import platform
import unittest2 as unittest
import httplib2
import googleapiclient.model

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

from six.moves.urllib.parse import parse_qs

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


class Model(unittest.TestCase):
Expand Down