Skip to content

Commit 941ad3d

Browse files
committed
fix: Use version.py instead of pkg_resources
1 parent 3183285 commit 941ad3d

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

googleapiclient/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
import json
2828
import logging
2929
import platform
30-
import pkg_resources
3130

3231
from six.moves.urllib.parse import urlencode
3332

33+
from googleapiclient import version as googleapiclient_version
3434
from googleapiclient.errors import HttpError
3535

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

3939
LOGGER = logging.getLogger(__name__)

googleapiclient/version.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2022 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.12.0"

setup.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
readme = readme_file.read()
5555

5656
version = "1.12.10"
57+
package_root = os.path.abspath(os.path.dirname(__file__))
58+
59+
version = {}
60+
with open(os.path.join(package_root, "googleapiclient/version.py")) as fp:
61+
exec(fp.read(), version)
62+
version = version["__version__"]
5763

5864
setup(
5965
name="google-api-python-client",

tests/test_json_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@
2626
import copy
2727
import json
2828
import os
29-
import pkg_resources
3029
import platform
3130
import unittest2 as unittest
3231
import httplib2
3332
import googleapiclient.model
3433

34+
from googleapiclient import version as googleapiclient_version
3535
from googleapiclient.errors import HttpError
3636
from googleapiclient.model import JsonModel
3737

3838
from six.moves.urllib.parse import parse_qs
3939

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

4242

4343
class Model(unittest.TestCase):

0 commit comments

Comments
 (0)