|
18 | 18 | __version__ = package_version.__version__ |
19 | 19 |
|
20 | 20 |
|
21 | | -import google.api_core as api_core |
22 | | - |
23 | | -if hasattr(api_core, "check_python_version") and hasattr( |
24 | | - api_core, "check_dependency_versions" |
25 | | -): # pragma: NO COVER |
26 | | - api_core.check_python_version("google.cloud.hypercomputecluster_v1beta") # type: ignore |
27 | | - api_core.check_dependency_versions("google.cloud.hypercomputecluster_v1beta") # type: ignore |
28 | | -else: # pragma: NO COVER |
29 | | - # An older version of api_core is installed which does not define the |
30 | | - # functions above. We do equivalent checks manually. |
31 | | - try: |
32 | | - import sys |
33 | | - import warnings |
34 | | - |
35 | | - _py_version_str = sys.version.split()[0] |
36 | | - _package_label = "google.cloud.hypercomputecluster_v1beta" |
37 | | - if sys.version_info < (3, 9): |
38 | | - warnings.warn( |
39 | | - "You are using a non-supported Python version " |
40 | | - + f"({_py_version_str}). Google will not post any further " |
41 | | - + f"updates to {_package_label} supporting this Python version. " |
42 | | - + "Please upgrade to the latest Python version, or at " |
43 | | - + f"least to Python 3.9, and then update {_package_label}.", |
44 | | - FutureWarning, |
45 | | - ) |
46 | | - if sys.version_info[:2] == (3, 9): |
47 | | - warnings.warn( |
48 | | - f"You are using a Python version ({_py_version_str}) " |
49 | | - + f"which Google will stop supporting in {_package_label} in " |
50 | | - + "January 2026. Please " |
51 | | - + "upgrade to the latest Python version, or at " |
52 | | - + "least to Python 3.10, before then, and " |
53 | | - + f"then update {_package_label}.", |
54 | | - FutureWarning, |
55 | | - ) |
56 | | - |
57 | | - from packaging.version import parse as parse_version |
58 | | - |
59 | | - if sys.version_info < (3, 8): |
60 | | - import pkg_resources |
61 | | - |
62 | | - def _get_version(dependency_name): |
63 | | - try: |
64 | | - version_string = pkg_resources.get_distribution( |
65 | | - dependency_name |
66 | | - ).version |
67 | | - return (parse_version(version_string), version_string) |
68 | | - except pkg_resources.DistributionNotFound: |
69 | | - return (None, "--") |
70 | | - |
71 | | - else: |
72 | | - from importlib import metadata |
73 | | - |
74 | | - def _get_version(dependency_name): |
75 | | - try: |
76 | | - version_string = metadata.version("requests") |
77 | | - parsed_version = parse_version(version_string) |
78 | | - return (parsed_version.release, version_string) |
79 | | - except metadata.PackageNotFoundError: |
80 | | - return (None, "--") |
81 | | - |
82 | | - _dependency_package = "google.protobuf" |
83 | | - _next_supported_version = "4.25.8" |
84 | | - _next_supported_version_tuple = (4, 25, 8) |
85 | | - _recommendation = " (we recommend 6.x)" |
86 | | - (_version_used, _version_used_string) = _get_version(_dependency_package) |
87 | | - if _version_used and _version_used < _next_supported_version_tuple: |
88 | | - warnings.warn( |
89 | | - f"Package {_package_label} depends on " |
90 | | - + f"{_dependency_package}, currently installed at version " |
91 | | - + f"{_version_used_string}. Future updates to " |
92 | | - + f"{_package_label} will require {_dependency_package} at " |
93 | | - + f"version {_next_supported_version} or higher{_recommendation}." |
94 | | - + " Please ensure " |
95 | | - + "that either (a) your Python environment doesn't pin the " |
96 | | - + f"version of {_dependency_package}, so that updates to " |
97 | | - + f"{_package_label} can require the higher version, or " |
98 | | - + "(b) you manually update your Python environment to use at " |
99 | | - + f"least version {_next_supported_version} of " |
100 | | - + f"{_dependency_package}.", |
101 | | - FutureWarning, |
102 | | - ) |
103 | | - except Exception: |
104 | | - warnings.warn( |
105 | | - "Could not determine the version of Python " |
106 | | - + "currently being used. To continue receiving " |
107 | | - + "updates for {_package_label}, ensure you are " |
108 | | - + "using a supported version of Python; see " |
109 | | - + "https://devguide.python.org/versions/" |
110 | | - ) |
111 | | - |
112 | | - |
113 | 21 | from .services.hypercompute_cluster import ( |
114 | 22 | HypercomputeClusterAsyncClient, |
115 | 23 | HypercomputeClusterClient, |
|
0 commit comments