epoplavskis / photon-pump

A TCP eventstore client for modern Python
MIT License
48 stars 9 forks source link

Broken with latest `protobuf`? #242

Open ross-at-bond opened 2 years ago

ross-at-bond commented 2 years ago

Looks like the package is broken with newer protobuf packages? I get this error message after a dependency update in a project using this module:

  ...
  File "/baas/app/eventstore/eventstore_db.py", line 4, in <module>
    import photonpump
  File "/usr/local/lib/python3.8/site-packages/photonpump/__init__.py", line 3, in <module>
    from .connection import *  # noqa
  File "/usr/local/lib/python3.8/site-packages/photonpump/connection.py", line 12, in <module>
    from . import conversations as convo
  File "/usr/local/lib/python3.8/site-packages/photonpump/conversations.py", line 16, in <module>
    from photonpump import messages
  File "/usr/local/lib/python3.8/site-packages/photonpump/messages.py", line 10, in <module>
    from . import messages_pb2
  File "/usr/local/lib/python3.8/site-packages/photonpump/messages_pb2.py", line 32, in <module>
    _descriptor.EnumValueDescriptor(
  File "/usr/local/lib/python3.8/site-packages/google/protobuf/descriptor.py", line 755, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
lisael commented 1 year ago

@ross-at-bond ^^this MR^^ fixes the issue... as long as you don't need a newer version of protobuf.