diff --git a/pkgs/development/python-modules/dbt-common/default.nix b/pkgs/development/python-modules/dbt-common/default.nix index 5880a9d479f9..66ff5dc526ef 100644 --- a/pkgs/development/python-modules/dbt-common/default.nix +++ b/pkgs/development/python-modules/dbt-common/default.nix @@ -44,12 +44,16 @@ buildPythonPackage rec { hash = "sha256-SIMg6ewnE6kY+drqcPlYrxt1XlWBurZU62FI/QnHAHY="; }; + patches = [ + # https://github.com/dbt-labs/dbt-common/pull/211 + ./protobuf_5.patch + ]; + build-system = [ hatchling ]; pythonRelaxDeps = [ "agate" "deepdiff" - "protobuf" ]; dependencies = [ diff --git a/pkgs/development/python-modules/dbt-common/protobuf_5.patch b/pkgs/development/python-modules/dbt-common/protobuf_5.patch new file mode 100644 index 000000000000..4573011301ef --- /dev/null +++ b/pkgs/development/python-modules/dbt-common/protobuf_5.patch @@ -0,0 +1,113 @@ +From f7c480139015cb8746f3fa751dc72b788d0ce8a0 Mon Sep 17 00:00:00 2001 +From: Eric Hauser +Date: Sat, 19 Oct 2024 15:52:16 -0600 +Subject: [PATCH] upgrade protobuf to >=5,<6 + +--- + dbt_common/events/base_types.py | 7 +++++-- + dbt_common/events/functions.py | 2 +- + dbt_common/events/types_pb2.py | 18 ++++++++++++++---- + pyproject.toml | 4 ++-- + 4 files changed, 22 insertions(+), 9 deletions(-) + +diff --git a/dbt_common/events/base_types.py b/dbt_common/events/base_types.py +index 781b2a0e..2f11e4c7 100644 +--- a/dbt_common/events/base_types.py ++++ b/dbt_common/events/base_types.py +@@ -91,15 +91,18 @@ def __getattr__(self, key): + + def to_dict(self): + return MessageToDict( +- self.pb_msg, preserving_proto_field_name=True, including_default_value_fields=True ++ self.pb_msg, ++ preserving_proto_field_name=True, ++ always_print_fields_with_no_presence=True, + ) + + def to_json(self) -> str: + return MessageToJson( + self.pb_msg, + preserving_proto_field_name=True, +- including_default_value_fields=True, ++ always_print_fields_with_no_presence=True, + indent=None, ++ sort_keys=True, + ) + + def level_tag(self) -> EventLevel: +diff --git a/dbt_common/events/functions.py b/dbt_common/events/functions.py +index 4e055aa4..86d68237 100644 +--- a/dbt_common/events/functions.py ++++ b/dbt_common/events/functions.py +@@ -97,7 +97,7 @@ def msg_to_dict(msg: EventMsg) -> dict: + msg_dict = MessageToDict( + msg, + preserving_proto_field_name=True, +- including_default_value_fields=True, # type: ignore ++ always_print_fields_with_no_presence=True, + ) + except Exception as exc: + event_type = type(msg).__name__ +diff --git a/dbt_common/events/types_pb2.py b/dbt_common/events/types_pb2.py +index 6574462e..1a3b91a5 100644 +--- a/dbt_common/events/types_pb2.py ++++ b/dbt_common/events/types_pb2.py +@@ -1,12 +1,22 @@ + # -*- coding: utf-8 -*- + # Generated by the protocol buffer compiler. DO NOT EDIT! ++# NO CHECKED-IN PROTOBUF GENCODE + # source: types.proto +-# Protobuf Python Version: 4.25.2 ++# Protobuf Python Version: 5.28.2 + """Generated protocol buffer code.""" + from google.protobuf import descriptor as _descriptor + from google.protobuf import descriptor_pool as _descriptor_pool ++from google.protobuf import runtime_version as _runtime_version + from google.protobuf import symbol_database as _symbol_database + from google.protobuf.internal import builder as _builder ++_runtime_version.ValidateProtobufRuntimeVersion( ++ _runtime_version.Domain.PUBLIC, ++ 5, ++ 28, ++ 2, ++ '', ++ 'types.proto' ++) + # @@protoc_insertion_point(imports) + + _sym_db = _symbol_database.Default() +@@ -20,9 +30,9 @@ + _globals = globals() + _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) + _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'types_pb2', _globals) +-if _descriptor._USE_C_DESCRIPTORS == False: +- DESCRIPTOR._options = None +- _globals['_EVENTINFO_EXTRAENTRY']._options = None ++if not _descriptor._USE_C_DESCRIPTORS: ++ DESCRIPTOR._loaded_options = None ++ _globals['_EVENTINFO_EXTRAENTRY']._loaded_options = None + _globals['_EVENTINFO_EXTRAENTRY']._serialized_options = b'8\001' + _globals['_EVENTINFO']._serialized_start=62 + _globals['_EVENTINFO']._serialized_end=335 +diff --git a/pyproject.toml b/pyproject.toml +index 2e40385c..c2878d15 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -36,7 +36,7 @@ dependencies = [ + "Jinja2>=3.1.3,<4", + "mashumaro[msgpack]>=3.9,<4.0", + "pathspec>=0.9,<0.13", +- "protobuf>=4.0.0,<5.0.0", ++ "protobuf>=5.0,<6.0", + "python-dateutil>=2.0,<3.0", + "requests<3.0.0", # needs to match dbt-core + "typing-extensions>=4.4,<5.0", +@@ -52,7 +52,7 @@ lint = [ + "pytest>=7.3,<8.0", # needed for linting tests + "types-Jinja2>=2.11,<3.0", + "types-jsonschema>=4.17,<5.0", +- "types-protobuf>=4.24,<5.0", ++ "types-protobuf>=5.0,<6.0", + "types-python-dateutil>=2.8,<3.0", + "types-PyYAML>=6.0,<7.0", + "types-requests"