__init__.py 781 B

123456789101112131415161718192021
  1. """Vendored protobuf bindings for the Chatto realtime WebSocket protocol.
  2. Generated modules under this directory import each other via top-level package
  3. paths (``from chatto.api.v1 import ...``, ``from buf.validate import ...``)
  4. because that is how ``protoc`` emits Python bindings. To make them importable
  5. without polluting the top-level ``chatto`` / ``buf`` namespaces of dependent
  6. projects, this package inserts its own directory into ``sys.path`` on first
  7. import. Chatto is the only real project shipping under those names, so the
  8. collision risk is negligible.
  9. Regenerate with ``scripts/generate_pb.sh``.
  10. """
  11. from __future__ import annotations
  12. import os
  13. import sys
  14. _here = os.path.dirname(os.path.abspath(__file__))
  15. if _here not in sys.path:
  16. sys.path.insert(0, _here)