Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ from .types.{{ proto.module_name }} import {{ enum.name }}
api_core.check_python_version("{{package_path}}")
api_core.check_dependency_versions("{{package_path}}")

_PQC_GRPC_WARNING_TEMPLATE = (
"Package {consumer_package} depends on {dependency_package}, currently installed at version {version_used_string}. "
"grpcio < 1.83.0 does not support Post-Quantum Cryptography (PQC). "
"Support for non-PQC environments is deprecated. In October 2026, "
"Google Cloud Python client libraries will raise their minimum requirements "
"(including google-api-core, grpcio, and grpcio-status) to enforce grpcio >= 1.83.0. "
"For more details on Google Cloud's post-quantum security migration, visit: "
"https://cloud.google.com/security/resources/post-quantum-cryptography"
)

api_core.warn_deprecation_for_versions_less_than(
"{{package_path}}",
"grpcio",
"1.83.0",
message_template=_PQC_GRPC_WARNING_TEMPLATE,
)

{# Define __all__.
This requires the full set of imported names, so we iterate over
them again.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,30 @@
api_core.check_python_version("google.cloud.asset_v1")
api_core.check_dependency_versions("google.cloud.asset_v1")

try:
from google.api_core._python_package_support import (
warn_deprecation_for_versions_less_than,
)

_PQC_GRPC_WARNING_TEMPLATE = (
"Package {consumer_package} depends on {dependency_package}, currently installed at version {version_used_string}. "
"grpcio < 1.83.0 does not support Post-Quantum Cryptography (PQC). "
"Support for non-PQC environments is deprecated. In October 2026, "
"Google Cloud Python client libraries will raise their minimum requirements "
"(including google-api-core, grpcio, and grpcio-status) to enforce grpcio >= 1.83.0. "
"For more details on Google Cloud's post-quantum security migration, visit: "
"https://cloud.google.com/security/resources/post-quantum-cryptography"
)

warn_deprecation_for_versions_less_than(
"google.cloud.asset_v1",
"grpcio",
"1.83.0",
message_template=_PQC_GRPC_WARNING_TEMPLATE,
)
except Exception:
pass

__all__ = (
'AssetServiceAsyncClient',
'AnalyzeIamPolicyLongrunningMetadata',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,30 @@
api_core.check_python_version("google.iam.credentials_v1")
api_core.check_dependency_versions("google.iam.credentials_v1")

try:
from google.api_core._python_package_support import (
warn_deprecation_for_versions_less_than,
)

_PQC_GRPC_WARNING_TEMPLATE = (
"Package {consumer_package} depends on {dependency_package}, currently installed at version {version_used_string}. "
"grpcio < 1.83.0 does not support Post-Quantum Cryptography (PQC). "
"Support for non-PQC environments is deprecated. In October 2026, "
"Google Cloud Python client libraries will raise their minimum requirements "
"(including google-api-core, grpcio, and grpcio-status) to enforce grpcio >= 1.83.0. "
"For more details on Google Cloud's post-quantum security migration, visit: "
"https://cloud.google.com/security/resources/post-quantum-cryptography"
)

warn_deprecation_for_versions_less_than(
"google.iam.credentials_v1",
"grpcio",
"1.83.0",
message_template=_PQC_GRPC_WARNING_TEMPLATE,
)
except Exception:
pass

__all__ = (
'IAMCredentialsAsyncClient',
'GenerateAccessTokenRequest',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,30 @@
api_core.check_python_version("google.cloud.eventarc_v1")
api_core.check_dependency_versions("google.cloud.eventarc_v1")

try:
from google.api_core._python_package_support import (
warn_deprecation_for_versions_less_than,
)

_PQC_GRPC_WARNING_TEMPLATE = (
"Package {consumer_package} depends on {dependency_package}, currently installed at version {version_used_string}. "
"grpcio < 1.83.0 does not support Post-Quantum Cryptography (PQC). "
"Support for non-PQC environments is deprecated. In October 2026, "
"Google Cloud Python client libraries will raise their minimum requirements "
"(including google-api-core, grpcio, and grpcio-status) to enforce grpcio >= 1.83.0. "
"For more details on Google Cloud's post-quantum security migration, visit: "
"https://cloud.google.com/security/resources/post-quantum-cryptography"
)

warn_deprecation_for_versions_less_than(
"google.cloud.eventarc_v1",
"grpcio",
"1.83.0",
message_template=_PQC_GRPC_WARNING_TEMPLATE,
)
except Exception:
pass

__all__ = (
'EventarcAsyncClient',
'Channel',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,30 @@
api_core.check_python_version("google.cloud.logging_v2")
api_core.check_dependency_versions("google.cloud.logging_v2")

try:
from google.api_core._python_package_support import (
warn_deprecation_for_versions_less_than,
)

_PQC_GRPC_WARNING_TEMPLATE = (
"Package {consumer_package} depends on {dependency_package}, currently installed at version {version_used_string}. "
"grpcio < 1.83.0 does not support Post-Quantum Cryptography (PQC). "
"Support for non-PQC environments is deprecated. In October 2026, "
"Google Cloud Python client libraries will raise their minimum requirements "
"(including google-api-core, grpcio, and grpcio-status) to enforce grpcio >= 1.83.0. "
"For more details on Google Cloud's post-quantum security migration, visit: "
"https://cloud.google.com/security/resources/post-quantum-cryptography"
)

warn_deprecation_for_versions_less_than(
"google.cloud.logging_v2",
"grpcio",
"1.83.0",
message_template=_PQC_GRPC_WARNING_TEMPLATE,
)
except Exception:
pass

__all__ = (
'ConfigServiceV2AsyncClient',
'LoggingServiceV2AsyncClient',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,30 @@
api_core.check_python_version("google.cloud.logging_v2")
api_core.check_dependency_versions("google.cloud.logging_v2")

try:
from google.api_core._python_package_support import (
warn_deprecation_for_versions_less_than,
)

_PQC_GRPC_WARNING_TEMPLATE = (
"Package {consumer_package} depends on {dependency_package}, currently installed at version {version_used_string}. "
"grpcio < 1.83.0 does not support Post-Quantum Cryptography (PQC). "
"Support for non-PQC environments is deprecated. In October 2026, "
"Google Cloud Python client libraries will raise their minimum requirements "
"(including google-api-core, grpcio, and grpcio-status) to enforce grpcio >= 1.83.0. "
"For more details on Google Cloud's post-quantum security migration, visit: "
"https://cloud.google.com/security/resources/post-quantum-cryptography"
)

warn_deprecation_for_versions_less_than(
"google.cloud.logging_v2",
"grpcio",
"1.83.0",
message_template=_PQC_GRPC_WARNING_TEMPLATE,
)
except Exception:
pass

__all__ = (
'BaseConfigServiceV2AsyncClient',
'BaseMetricsServiceV2AsyncClient',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,30 @@
api_core.check_python_version("google.cloud.redis_v1")
api_core.check_dependency_versions("google.cloud.redis_v1")

try:
from google.api_core._python_package_support import (
warn_deprecation_for_versions_less_than,
)

_PQC_GRPC_WARNING_TEMPLATE = (
"Package {consumer_package} depends on {dependency_package}, currently installed at version {version_used_string}. "
"grpcio < 1.83.0 does not support Post-Quantum Cryptography (PQC). "
"Support for non-PQC environments is deprecated. In October 2026, "
"Google Cloud Python client libraries will raise their minimum requirements "
"(including google-api-core, grpcio, and grpcio-status) to enforce grpcio >= 1.83.0. "
"For more details on Google Cloud's post-quantum security migration, visit: "
"https://cloud.google.com/security/resources/post-quantum-cryptography"
)

warn_deprecation_for_versions_less_than(
"google.cloud.redis_v1",
"grpcio",
"1.83.0",
message_template=_PQC_GRPC_WARNING_TEMPLATE,
)
except Exception:
pass

__all__ = (
'CloudRedisAsyncClient',
'CloudRedisClient',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,30 @@
api_core.check_python_version("google.cloud.redis_v1")
api_core.check_dependency_versions("google.cloud.redis_v1")

try:
from google.api_core._python_package_support import (
warn_deprecation_for_versions_less_than,
)

_PQC_GRPC_WARNING_TEMPLATE = (
"Package {consumer_package} depends on {dependency_package}, currently installed at version {version_used_string}. "
"grpcio < 1.83.0 does not support Post-Quantum Cryptography (PQC). "
"Support for non-PQC environments is deprecated. In October 2026, "
"Google Cloud Python client libraries will raise their minimum requirements "
"(including google-api-core, grpcio, and grpcio-status) to enforce grpcio >= 1.83.0. "
"For more details on Google Cloud's post-quantum security migration, visit: "
"https://cloud.google.com/security/resources/post-quantum-cryptography"
)

warn_deprecation_for_versions_less_than(
"google.cloud.redis_v1",
"grpcio",
"1.83.0",
message_template=_PQC_GRPC_WARNING_TEMPLATE,
)
except Exception:
pass

__all__ = (
'CloudRedisAsyncClient',
'CloudRedisClient',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,30 @@
api_core.check_python_version("google.cloud.storagebatchoperations_v1")
api_core.check_dependency_versions("google.cloud.storagebatchoperations_v1")

try:
from google.api_core._python_package_support import (
warn_deprecation_for_versions_less_than,
)

_PQC_GRPC_WARNING_TEMPLATE = (
"Package {consumer_package} depends on {dependency_package}, currently installed at version {version_used_string}. "
"grpcio < 1.83.0 does not support Post-Quantum Cryptography (PQC). "
"Support for non-PQC environments is deprecated. In October 2026, "
"Google Cloud Python client libraries will raise their minimum requirements "
"(including google-api-core, grpcio, and grpcio-status) to enforce grpcio >= 1.83.0. "
"For more details on Google Cloud's post-quantum security migration, visit: "
"https://cloud.google.com/security/resources/post-quantum-cryptography"
)

warn_deprecation_for_versions_less_than(
"google.cloud.storagebatchoperations_v1",
"grpcio",
"1.83.0",
message_template=_PQC_GRPC_WARNING_TEMPLATE,
)
except Exception:
pass

__all__ = (
'StorageBatchOperationsAsyncClient',
'BucketList',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,37 @@
# about deprecated and unsupported versions.
DependencyConstraint = namedtuple(
"DependencyConstraint",
["package_name", "minimum_fully_supported_version", "recommended_version"],
[
"package_name",
"minimum_fully_supported_version",
"recommended_version",
"message_template",
],
defaults=(None, None),
)

PQC_GRPC_WARNING_TEMPLATE = (
"Package {consumer_package} depends on {dependency_package}, currently installed at version {version_used_string}. "
"grpcio < 1.83.0 does not support Post-Quantum Cryptography (PQC). "
"Support for non-PQC environments is deprecated. In October 2026, "
"Google Cloud Python packages will raise their minimum requirements "
"(including google-api-core, grpcio, and grpcio-status) to enforce grpcio >= 1.83.0. "
"For more details on Google Cloud's post-quantum security migration, visit: "
"https://cloud.google.com/security/resources/post-quantum-cryptography"
)

_PACKAGE_DEPENDENCY_WARNINGS = [
DependencyConstraint(
"google.protobuf",
minimum_fully_supported_version="6.33.5",
recommended_version="6.x",
)
),
DependencyConstraint(
"grpcio",
minimum_fully_supported_version="1.83.0",
recommended_version="1.83.x",
message_template=PQC_GRPC_WARNING_TEMPLATE,
),
]


Expand Down Expand Up @@ -162,7 +185,7 @@ def warn_deprecation_for_versions_less_than(
) = _get_distribution_and_import_packages(consumer_import_package)

recommendation = (
" (we recommend {recommended_version})" if recommended_version else ""
f" (we recommend {recommended_version})" if recommended_version else ""
)
message_template = message_template or _flatten_message(
"""
Expand Down Expand Up @@ -222,4 +245,5 @@ def check_dependency_versions(
package_info.package_name,
package_info.minimum_fully_supported_version,
recommended_version=package_info.recommended_version,
message_template=package_info.message_template,
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import pytest

from google.api_core._python_package_support import (
PQC_GRPC_WARNING_TEMPLATE,
DependencyConstraint,
DependencyVersion,
check_dependency_versions,
Expand All @@ -37,11 +38,10 @@ def test_get_dependency_version(mocker, version_string_to_test):
parse_version_to_tuple(version_string_to_test), version_string_to_test
)
assert get_dependency_version("some-package") == expected

mock_importlib.assert_called_once_with("some-package")

# Test package not found
mock_importlib.side_effect = ImportError
mock_importlib.side_effect = Exception
assert get_dependency_version("not-a-package") == DependencyVersion(None, "--")


Expand Down Expand Up @@ -125,8 +125,40 @@ def test_check_dependency_versions_with_custom_warnings(mock_warn):

assert mock_warn.call_count == 2
mock_warn.assert_any_call(
"my-consumer", "pkg1", "1.0.0", recommended_version="2.0.0"
"my-consumer",
"pkg1",
"1.0.0",
recommended_version="2.0.0",
message_template=None,
)
mock_warn.assert_any_call(
"my-consumer",
"pkg2",
"2.0.0",
recommended_version="3.0.0",
message_template=None,
)


@patch(
"google.api_core._python_package_support.warn_deprecation_for_versions_less_than"
)
def test_check_dependency_versions_default(mock_warn):
"""Test check_dependency_versions with default package dependency warnings."""
check_dependency_versions("my-consumer")

assert mock_warn.call_count == 2
mock_warn.assert_any_call(
"my-consumer",
"google.protobuf",
"6.33.5",
recommended_version="6.x",
message_template=None,
)
mock_warn.assert_any_call(
"my-consumer", "pkg2", "2.0.0", recommended_version="3.0.0"
"my-consumer",
"grpcio",
"1.83.0",
recommended_version="1.83.x",
message_template=PQC_GRPC_WARNING_TEMPLATE,
)
Loading
Loading