Skip to content

Commit 80b38ea

Browse files
kyohei3parthea
andauthored
fix: Use version.py instead of pkg_resources (#1677)
* fix: Use version.py instead of pkg_resources * remove unused code Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent 3183285 commit 80b38ea

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

googleapiclient/model.py

+2-2
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

+15
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

+6-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@
5353
with io.open(readme_filename, encoding="utf-8") as readme_file:
5454
readme = readme_file.read()
5555

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

5863
setup(
5964
name="google-api-python-client",

tests/test_json_model.py

+2-2
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)