__init__.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright 2014-2016 OpenMarket Ltd
  2. # Copyright 2018-9 New Vector Ltd
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. """ This is a reference implementation of a Matrix homeserver.
  16. """
  17. import json
  18. import os
  19. import sys
  20. # Check that we're not running on an unsupported Python version.
  21. if sys.version_info < (3, 6):
  22. print("Synapse requires Python 3.6 or above.")
  23. sys.exit(1)
  24. # Twisted and canonicaljson will fail to import when this file is executed to
  25. # get the __version__ during a fresh install. That's OK and subsequent calls to
  26. # actually start Synapse will import these libraries fine.
  27. try:
  28. from twisted.internet import protocol
  29. from twisted.internet.protocol import Factory
  30. from twisted.names.dns import DNSDatagramProtocol
  31. protocol.Factory.noisy = False
  32. Factory.noisy = False
  33. DNSDatagramProtocol.noisy = False
  34. except ImportError:
  35. pass
  36. # Use the standard library json implementation instead of simplejson.
  37. try:
  38. from canonicaljson import set_json_library
  39. set_json_library(json)
  40. except ImportError:
  41. pass
  42. __version__ = "1.45.1"
  43. if bool(os.environ.get("SYNAPSE_TEST_PATCH_LOG_CONTEXTS", False)):
  44. # We import here so that we don't have to install a bunch of deps when
  45. # running the packaging tox test.
  46. from synapse.util.patch_inline_callbacks import do_patch
  47. do_patch()