Repository: googleapis/google-api-python-client (python)

Issue:
Use version.py instead of pkg_resource
I met the same issue on the google-api-python-client about the pkg_resources exception (
https://github.com/googleapis/python-api-core/issues/27)
https://github.com/googleapis/google-api-python-client/blob/0f2e2a13bf8f4e4150fed1f79cf995309ddc34f1/googleapiclient/model.py#L34

```
pkg_resources.DistributionNotFound: The 'google-api-python-client' distribution was not found and is required by the application
```

I found the google-auth source and python-api-core has changed. Could it be changed this way accordingly?
https://github.com/googleapis/google-auth-library-python/pull/683/commits/ff6b52ccbb3811dbc5adcb2c12f6d66fa4e8ef78

Pull request description:
feat: expose library version at googleapiclient.__version__
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [V] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/google-api-python-client/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [V] Ensure the tests and linter pass
- [V] Code coverage does not decrease (if any source code was changed)
- [V] Appropriate docs were updated (if necessary)

Fixes #1622 🦕


Patch:
diff --git a/googleapiclient/model.py b/googleapiclient/model.py
index b023db4dd..3d1f39769 100644
--- a/googleapiclient/model.py
+++ b/googleapiclient/model.py
@@ -26,12 +26,12 @@ __author__ = "jcgregorio@google.com (Joe Gregorio)"
 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__)
diff --git a/googleapiclient/version.py b/googleapiclient/version.py
new file mode 100644
index 000000000..5b915cede
--- /dev/null
+++ b/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" 
diff --git a/setup.py b/setup.py
index ed8fa9bc9..a311f1685 100644
--- a/setup.py
+++ b/setup.py
@@ -51,7 +51,12 @@ readme_filename = os.path.join(package_root, "README.md")
 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",


Test patch:
diff --git a/tests/test_json_model.py b/tests/test_json_model.py
index 322a7b484..533361c36 100644
--- a/tests/test_json_model.py
+++ b/tests/test_json_model.py
@@ -25,17 +25,17 @@ __author__ = "jcgregorio@google.com (Joe Gregorio)"
 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'