@@ -10,76 +10,77 @@ __version__ = package_version.__version__
10
10
11
11
import google.api_core as api_core
12
12
13
- try :
14
- api_core.check_python_version("{{package_path}}")
15
- api_core.check_dependency_versions("{{package_path}}")
16
- except AttributeError :
13
+ if hasattr(api_core, "check_python_version") and hasattr(api_core, "check_dependency_versions") :
14
+ api_core.check_python_version("{{package_path}}")
15
+ api_core.check_dependency_versions("{{package_path}}")
16
+ else :
17
17
{# TODO: Remove this try-catch when we require api-core at a version that
18
18
supports the changes in https://github.com/googleapis/python-api-core/pull/832
19
19
20
20
In the meantime, please ensure the functionality here mirrors the
21
- equivalent functionality in api_core, in those two functions above.
21
+ equivalent functionality in api_core, in those two functions above.
22
22
#}
23
- # An older version of api_core is installed, which does not define the
24
- # functions above. We do equivalent checks manually.
25
-
26
- import logging
27
- import sys
28
-
29
- _py_version_str = sys.version.split()[0]
30
- _package_label = "{{package_path}}"
31
- if sys.version_info < (3, 9):
32
- logging.warning("You are using a non-supported Python version " +
33
- f"({_py_version_str}). Google will not post any further " +
34
- f"updates to {_package_label} supporting this Python version. " +
35
- "Please upgrade to the latest Python version, or at " +
36
- f"least to Python 3.9, and then update {_package_label}.")
37
- if sys.version_info[:2] == (3, 9):
38
- logging.warning(f"You are using a Python version ({_py_version_str}) " +
39
- f"which Google will stop supporting in {_package_label} when " +
40
- "it reaches its end of life (October 2025). Please " +
41
- "upgrade to the latest Python version, or at " +
42
- "least Python 3.10, before then, and " +
43
- f"then update {_package_label}.")
44
-
45
- from packaging.version import parse as parse_version
46
-
47
- if sys.version_info < (3, 8):
48
- import pkg_resources
49
- def _get_version(dependency_name):
50
- try:
51
- version_string = pkg_resources.get_distribution(dependency_name).version
52
- return parse_version(version_string)
53
- except pkg_resources.DistributionNotFound:
54
- return None
55
- else:
56
- from importlib import metadata
57
-
58
- def _get_version(dependency_name):
59
- try:
60
- version_string = metadata.version("requests")
61
- parsed_version = parse_version(version_string)
62
- return parsed_version.release
63
- except metadata.PackageNotFoundError:
64
- return None
65
-
66
- _dependency_package = "google.protobuf"
67
- _next_supported_version = "4.25.8"
68
- _next_supported_version_tuple = (4, 25, 8)
69
- _version_used = _get_version(_dependency_package)
70
- if _version_used and _version_used < _next_supported_version_tuple:
71
- logging.warning(f"DEPRECATION: Package {_package_label} depends on " +
72
- f"{_dependency_package}, currently installed at version " +
73
- f"{_version_used.__str__}. Future updates to " +
74
- f"{_package_label} will require {_dependency_package} at " +
75
- f"version {_next_supported_version} or higher. Please ensure " +
76
- "that either (a) your Python environment doesn't pin the " +
77
- f"version of {_dependency_package}, so that updates to " +
78
- f"{_package_label} can require the higher version, or " +
79
- "(b) you manually update your Python environment to use at " +
80
- f"least version {_next_supported_version} of " +
81
- f"{_dependency_package}.")
82
-
23
+ # An older version of api_core is installed, which does not define the
24
+ # functions above. We do equivalent checks manually.
25
+
26
+ import logging
27
+ import sys
28
+
29
+ _py_version_str = sys.version.split()[0]
30
+ _package_label = "{{package_path}}"
31
+ if sys.version_info < (3, 9):
32
+ logging.warning("You are using a non-supported Python version " +
33
+ f"({_py_version_str}). Google will not post any further " +
34
+ f"updates to {_package_label} supporting this Python version. " +
35
+ "Please upgrade to the latest Python version, or at " +
36
+ f"least to Python 3.9, and then update {_package_label}.")
37
+ if sys.version_info[:2] == (3, 9):
38
+ logging.warning(f"You are using a Python version ({_py_version_str}) " +
39
+ f"which Google will stop supporting in {_package_label} when " +
40
+ "it reaches its end of life (October 2025). Please " +
41
+ "upgrade to the latest Python version, or at " +
42
+ "least Python 3.10, before then, and " +
43
+ f"then update {_package_label}.")
44
+
45
+ from packaging.version import parse as parse_version
46
+
47
+ if sys.version_info < (3, 8):
48
+ import pkg_resources
49
+
50
+ def _get_version(dependency_name):
51
+ try:
52
+ version_string = pkg_resources.get_distribution(dependency_name).version
53
+ return parse_version(version_string)
54
+ except pkg_resources.DistributionNotFound:
55
+ return None
56
+ else:
57
+ from importlib import metadata
58
+
59
+ def _get_version(dependency_name):
60
+ try:
61
+ version_string = metadata.version("requests")
62
+ parsed_version = parse_version(version_string)
63
+ return parsed_version.release
64
+ except metadata.PackageNotFoundError:
65
+ return None
66
+
67
+ _dependency_package = "google.protobuf"
68
+ _next_supported_version = "4.25.8"
69
+ _next_supported_version_tuple = (4, 25, 8)
70
+ _version_used = _get_version(_dependency_package)
71
+ if _version_used and _version_used < _next_supported_version_tuple:
72
+ logging.warning(f"DEPRECATION: Package {_package_label} depends on " +
73
+ f"{_dependency_package}, currently installed at version " +
74
+ f"{_version_used.__str__}. Future updates to " +
75
+ f"{_package_label} will require {_dependency_package} at " +
76
+ f"version {_next_supported_version} or higher. Please ensure " +
77
+ "that either (a) your Python environment doesn't pin the " +
78
+ f"version of {_dependency_package}, so that updates to " +
79
+ f"{_package_label} can require the higher version, or " +
80
+ "(b) you manually update your Python environment to use at " +
81
+ f"least version {_next_supported_version} of " +
82
+ f"{_dependency_package}.")
83
+
83
84
{# Import subpackages. -#}
84
85
{% for subpackage , _ in api .subpackages |dictsort %}
85
86
from . import {{ subpackage }}
0 commit comments