pyproject.toml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. [tool.towncrier]
  2. package = "synapse"
  3. filename = "CHANGES.md"
  4. directory = "changelog.d"
  5. issue_format = "[\\#{issue}](https://github.com/matrix-org/synapse/issues/{issue})"
  6. [[tool.towncrier.type]]
  7. directory = "feature"
  8. name = "Features"
  9. showcontent = true
  10. [[tool.towncrier.type]]
  11. directory = "bugfix"
  12. name = "Bugfixes"
  13. showcontent = true
  14. [[tool.towncrier.type]]
  15. directory = "docker"
  16. name = "Updates to the Docker image"
  17. showcontent = true
  18. [[tool.towncrier.type]]
  19. directory = "doc"
  20. name = "Improved Documentation"
  21. showcontent = true
  22. [[tool.towncrier.type]]
  23. directory = "removal"
  24. name = "Deprecations and Removals"
  25. showcontent = true
  26. [[tool.towncrier.type]]
  27. directory = "misc"
  28. name = "Internal Changes"
  29. showcontent = true
  30. [tool.black]
  31. target-version = ['py37', 'py38', 'py39', 'py310']
  32. # black ignores everything in .gitignore by default, see
  33. # https://black.readthedocs.io/en/stable/usage_and_configuration/file_collection_and_discovery.html#gitignore
  34. # Use `extend-exclude` if you want to exclude something in addition to this.
  35. [tool.ruff]
  36. line-length = 88
  37. # See https://github.com/charliermarsh/ruff/#pycodestyle
  38. # for error codes. The ones we ignore are:
  39. # E731: do not assign a lambda expression, use a def
  40. # E501: Line too long (black enforces this for us)
  41. #
  42. # See https://github.com/charliermarsh/ruff/#pyflakes
  43. # F401: unused import
  44. # F811: Redefinition of unused
  45. # F821: Undefined name
  46. #
  47. # flake8-bugbear compatible checks. Its error codes are described at
  48. # https://github.com/charliermarsh/ruff/#flake8-bugbear
  49. # B019: Use of functools.lru_cache or functools.cache on methods can lead to memory leaks
  50. # B023: Functions defined inside a loop must not use variables redefined in the loop
  51. # B024: Abstract base class with no abstract method.
  52. ignore = [
  53. "B019",
  54. "B023",
  55. "B024",
  56. "E501",
  57. "E731",
  58. "F401",
  59. "F811",
  60. "F821",
  61. ]
  62. select = [
  63. # pycodestyle checks.
  64. "E",
  65. "W",
  66. # pyflakes checks.
  67. "F",
  68. # flake8-bugbear checks.
  69. "B0",
  70. # flake8-comprehensions checks.
  71. "C4",
  72. ]
  73. [tool.isort]
  74. line_length = 88
  75. sections = ["FUTURE", "STDLIB", "THIRDPARTY", "TWISTED", "FIRSTPARTY", "TESTS", "LOCALFOLDER"]
  76. default_section = "THIRDPARTY"
  77. known_first_party = ["synapse"]
  78. known_tests = ["tests"]
  79. known_twisted = ["twisted", "OpenSSL"]
  80. multi_line_output = 3
  81. include_trailing_comma = true
  82. combine_as_imports = true
  83. skip_gitignore = true
  84. [tool.maturin]
  85. manifest-path = "rust/Cargo.toml"
  86. [tool.poetry]
  87. name = "matrix-synapse"
  88. version = "1.74.0"
  89. description = "Homeserver for the Matrix decentralised comms protocol"
  90. authors = ["Matrix.org Team and Contributors <packages@matrix.org>"]
  91. license = "Apache-2.0"
  92. readme = "README.rst"
  93. repository = "https://github.com/matrix-org/synapse"
  94. packages = [
  95. { include = "synapse" },
  96. ]
  97. classifiers = [
  98. "Development Status :: 5 - Production/Stable",
  99. "Topic :: Communications :: Chat",
  100. ]
  101. include = [
  102. { path = "AUTHORS.rst", format = "sdist" },
  103. { path = "book.toml", format = "sdist" },
  104. { path = "changelog.d", format = "sdist" },
  105. { path = "CHANGES.md", format = "sdist" },
  106. { path = "CONTRIBUTING.md", format = "sdist" },
  107. { path = "demo", format = "sdist" },
  108. { path = "docs", format = "sdist" },
  109. { path = "INSTALL.md", format = "sdist" },
  110. { path = "mypy.ini", format = "sdist" },
  111. { path = "scripts-dev", format = "sdist" },
  112. { path = "synmark", format="sdist" },
  113. { path = "sytest-blacklist", format = "sdist" },
  114. { path = "tests", format = "sdist" },
  115. { path = "UPGRADE.rst", format = "sdist" },
  116. { path = "Cargo.toml", format = "sdist" },
  117. { path = "Cargo.lock", format = "sdist" },
  118. { path = "rust/Cargo.toml", format = "sdist" },
  119. { path = "rust/build.rs", format = "sdist" },
  120. { path = "rust/src/**", format = "sdist" },
  121. ]
  122. exclude = [
  123. { path = "synapse/*.so", format = "sdist"}
  124. ]
  125. build = "build_rust.py"
  126. [tool.poetry.scripts]
  127. synapse_homeserver = "synapse.app.homeserver:main"
  128. synapse_worker = "synapse.app.generic_worker:main"
  129. synctl = "synapse._scripts.synctl:main"
  130. export_signing_key = "synapse._scripts.export_signing_key:main"
  131. generate_config = "synapse._scripts.generate_config:main"
  132. generate_log_config = "synapse._scripts.generate_log_config:main"
  133. generate_signing_key = "synapse._scripts.generate_signing_key:main"
  134. hash_password = "synapse._scripts.hash_password:main"
  135. register_new_matrix_user = "synapse._scripts.register_new_matrix_user:main"
  136. synapse_port_db = "synapse._scripts.synapse_port_db:main"
  137. synapse_review_recent_signups = "synapse._scripts.review_recent_signups:main"
  138. update_synapse_database = "synapse._scripts.update_synapse_database:main"
  139. [tool.poetry.dependencies]
  140. python = "^3.7.1"
  141. # Mandatory Dependencies
  142. # ----------------------
  143. # we use the TYPE_CHECKER.redefine method added in jsonschema 3.0.0
  144. jsonschema = ">=3.0.0"
  145. # frozendict 2.1.2 is broken on Debian 10: https://github.com/Marco-Sulla/python-frozendict/issues/41
  146. frozendict = ">=1,!=2.1.2"
  147. # We require 2.1.0 or higher for type hints. Previous guard was >= 1.1.0
  148. unpaddedbase64 = ">=2.1.0"
  149. # We require 1.5.0 to work around an issue when running against the C implementation of
  150. # frozendict: https://github.com/matrix-org/python-canonicaljson/issues/36
  151. canonicaljson = "^1.5.0"
  152. # we use the type definitions added in signedjson 1.1.
  153. signedjson = "^1.1.0"
  154. # validating SSL certs for IP addresses requires service_identity 18.1.
  155. service-identity = ">=18.1.0"
  156. # Twisted 18.9 introduces some logger improvements that the structured
  157. # logger utilises
  158. Twisted = {extras = ["tls"], version = ">=18.9.0"}
  159. treq = ">=15.1"
  160. # Twisted has required pyopenssl 16.0 since about Twisted 16.6.
  161. pyOpenSSL = ">=16.0.0"
  162. PyYAML = ">=3.13"
  163. pyasn1 = ">=0.1.9"
  164. pyasn1-modules = ">=0.0.7"
  165. bcrypt = ">=3.1.7"
  166. Pillow = ">=5.4.0"
  167. # We use SortedDict.peekitem(), which was added in sortedcontainers 1.5.2.
  168. sortedcontainers = ">=1.5.2"
  169. pymacaroons = ">=0.13.0"
  170. msgpack = ">=0.5.2"
  171. phonenumbers = ">=8.2.0"
  172. # we use GaugeHistogramMetric, which was added in prom-client 0.4.0.
  173. prometheus-client = ">=0.4.0"
  174. # we use `order`, which arrived in attrs 19.2.0.
  175. # Note: 21.1.0 broke `/sync`, see #9936
  176. attrs = ">=19.2.0,!=21.1.0"
  177. netaddr = ">=0.7.18"
  178. # Jinja 2.x is incompatible with MarkupSafe>=2.1. To ensure that admins do not
  179. # end up with a broken installation, with recent MarkupSafe but old Jinja, we
  180. # add a lower bound to the Jinja2 dependency.
  181. Jinja2 = ">=3.0"
  182. bleach = ">=1.4.3"
  183. # We use `ParamSpec` and `Concatenate`, which were added in `typing-extensions` 3.10.0.0.
  184. # Additionally we need https://github.com/python/typing/pull/817 to allow types to be
  185. # generic over ParamSpecs.
  186. typing-extensions = ">=3.10.0.1"
  187. # We enforce that we have a `cryptography` version that bundles an `openssl`
  188. # with the latest security patches.
  189. cryptography = ">=3.4.7"
  190. # ijson 3.1.4 fixes a bug with "." in property names
  191. ijson = ">=3.1.4"
  192. matrix-common = "^1.3.0"
  193. # We need packaging.requirements.Requirement, added in 16.1.
  194. packaging = ">=16.1"
  195. # At the time of writing, we only use functions from the version `importlib.metadata`
  196. # which shipped in Python 3.8. This corresponds to version 1.4 of the backport.
  197. importlib_metadata = { version = ">=1.4", python = "<3.8" }
  198. # This is the most recent version of Pydantic with available on common distros.
  199. pydantic = ">=1.7.4"
  200. # This is for building the rust components during "poetry install", which
  201. # currently ignores the `build-system.requires` directive (c.f.
  202. # https://github.com/python-poetry/poetry/issues/6154). Both `pip install` and
  203. # `poetry build` do the right thing without this explicit dependency.
  204. #
  205. # This isn't really a dev-dependency, as `poetry install --no-dev` will fail,
  206. # but the alternative is to add it to the main list of deps where it isn't
  207. # needed.
  208. setuptools_rust = ">=1.3"
  209. # Optional Dependencies
  210. # ---------------------
  211. matrix-synapse-ldap3 = { version = ">=0.1", optional = true }
  212. psycopg2 = { version = ">=2.8", markers = "platform_python_implementation != 'PyPy'", optional = true }
  213. psycopg2cffi = { version = ">=2.8", markers = "platform_python_implementation == 'PyPy'", optional = true }
  214. psycopg2cffi-compat = { version = "==1.1", markers = "platform_python_implementation == 'PyPy'", optional = true }
  215. pysaml2 = { version = ">=4.5.0", optional = true }
  216. authlib = { version = ">=0.15.1", optional = true }
  217. # systemd-python is necessary for logging to the systemd journal via
  218. # `systemd.journal.JournalHandler`, as is documented in
  219. # `contrib/systemd/log_config.yaml`.
  220. # Note: systemd-python 231 appears to have been yanked from pypi
  221. systemd-python = { version = ">=231", optional = true }
  222. lxml = { version = ">=4.2.0", optional = true }
  223. sentry-sdk = { version = ">=0.7.2", optional = true }
  224. opentracing = { version = ">=2.2.0", optional = true }
  225. jaeger-client = { version = ">=4.0.0", optional = true }
  226. txredisapi = { version = ">=1.4.7", optional = true }
  227. hiredis = { version = "*", optional = true }
  228. Pympler = { version = "*", optional = true }
  229. parameterized = { version = ">=0.7.4", optional = true }
  230. idna = { version = ">=2.5", optional = true }
  231. pyicu = { version = ">=2.10.2", optional = true }
  232. [tool.poetry.extras]
  233. # NB: Packages that should be part of `pip install matrix-synapse[all]` need to be specified
  234. # twice: once here, and once in the `all` extra.
  235. matrix-synapse-ldap3 = ["matrix-synapse-ldap3"]
  236. postgres = ["psycopg2", "psycopg2cffi", "psycopg2cffi-compat"]
  237. saml2 = ["pysaml2"]
  238. oidc = ["authlib"]
  239. # systemd-python is necessary for logging to the systemd journal via
  240. # `systemd.journal.JournalHandler`, as is documented in
  241. # `contrib/systemd/log_config.yaml`.
  242. systemd = ["systemd-python"]
  243. url-preview = ["lxml"]
  244. sentry = ["sentry-sdk"]
  245. opentracing = ["jaeger-client", "opentracing"]
  246. jwt = ["authlib"]
  247. # hiredis is not a *strict* dependency, but it makes things much faster.
  248. # (if it is not installed, we fall back to slow code.)
  249. redis = ["txredisapi", "hiredis"]
  250. # Required to use experimental `caches.track_memory_usage` config option.
  251. cache-memory = ["pympler"]
  252. test = ["parameterized", "idna"]
  253. # Allows for better search for international characters in the user directory. This
  254. # requires libicu's development headers installed on the system (e.g. libicu-dev on
  255. # Debian-based distributions).
  256. user-search = ["pyicu"]
  257. # The duplication here is awful. I hate hate hate hate hate it. However, for now I want
  258. # to ensure you can still `pip install matrix-synapse[all]` like today. Two motivations:
  259. # 1) for new installations, I want instructions in existing documentation and tutorials
  260. # out there to still work.
  261. # 2) I don't want to hard-code a list of extras into CI if I can help it. The ideal
  262. # solution here would be something like https://github.com/python-poetry/poetry/issues/3413
  263. # Poetry 1.2's dependency groups might make this easier. But I'm not trying that out
  264. # until there's a stable release of 1.2.
  265. #
  266. # NB: the strings in this list must be *package* names, not extra names.
  267. # Some of our extra names _are_ package names, which can lead to great confusion.
  268. all = [
  269. # matrix-synapse-ldap3
  270. "matrix-synapse-ldap3",
  271. # postgres
  272. "psycopg2", "psycopg2cffi", "psycopg2cffi-compat",
  273. # saml2
  274. "pysaml2",
  275. # oidc and jwt
  276. "authlib",
  277. # url-preview
  278. "lxml",
  279. # sentry
  280. "sentry-sdk",
  281. # opentracing
  282. "jaeger-client", "opentracing",
  283. # redis
  284. "txredisapi", "hiredis",
  285. # cache-memory
  286. "pympler",
  287. # improved user search
  288. "pyicu",
  289. # omitted:
  290. # - test: it's useful to have this separate from dev deps in the olddeps job
  291. # - systemd: this is a system-based requirement
  292. ]
  293. [tool.poetry.dev-dependencies]
  294. # We pin black so that our tests don't start failing on new releases.
  295. isort = ">=5.10.1"
  296. black = ">=22.3.0"
  297. ruff = "0.0.189"
  298. # Typechecking
  299. mypy = "*"
  300. mypy-zope = "*"
  301. types-bleach = ">=4.1.0"
  302. types-commonmark = ">=0.9.2"
  303. types-jsonschema = ">=3.2.0"
  304. types-opentracing = ">=2.4.2"
  305. types-Pillow = ">=8.3.4"
  306. types-psycopg2 = ">=2.9.9"
  307. types-pyOpenSSL = ">=20.0.7"
  308. types-PyYAML = ">=5.4.10"
  309. types-requests = ">=2.26.0"
  310. types-setuptools = ">=57.4.0"
  311. # Dependencies which are exclusively required by unit test code. This is
  312. # NOT a list of all modules that are necessary to run the unit tests.
  313. # Tests assume that all optional dependencies are installed.
  314. # parameterized<0.7.4 can create classes with names that would normally be invalid
  315. # identifiers. trial really does not like this when running with multiple workers.
  316. parameterized = ">=0.7.4"
  317. idna = ">=2.5"
  318. # The following are used by the release script
  319. click = ">=8.1.3"
  320. # GitPython was == 3.1.14; bumped to 3.1.20, the first release with type hints.
  321. GitPython = ">=3.1.20"
  322. commonmark = ">=0.9.1"
  323. pygithub = ">=1.55"
  324. # The following are executed as commands by the release script.
  325. twine = "*"
  326. # Towncrier min version comes from #3425. Rationale unclear.
  327. towncrier = ">=18.6.0rc1"
  328. [build-system]
  329. # The upper bounds here are defensive, intended to prevent situations like
  330. # #13849 and #14079 where we see buildtime or runtime errors caused by build
  331. # system changes.
  332. # We are happy to raise these upper bounds upon request,
  333. # provided we check that it's safe to do so (i.e. that CI passes).
  334. requires = ["poetry-core>=1.0.0,<=1.3.2", "setuptools_rust>=1.3,<=1.5.2"]
  335. build-backend = "poetry.core.masonry.api"
  336. [tool.cibuildwheel]
  337. # Skip unsupported platforms (by us or by Rust).
  338. skip = "cp36* *-musllinux_i686 pp*aarch64 *-musllinux_aarch64"
  339. # We need a rust compiler
  340. before-all = "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y --profile minimal"
  341. environment= { PATH = "$PATH:$HOME/.cargo/bin" }
  342. # For some reason if we don't manually clean the build directory we
  343. # can end up polluting the next build with a .so that is for the wrong
  344. # Python version.
  345. before-build = "rm -rf {project}/build"
  346. build-frontend = "build"
  347. test-command = "python -c 'from synapse.synapse_rust import sum_as_string; print(sum_as_string(1, 2))'"
  348. [tool.cibuildwheel.linux]
  349. # Wrap the repair command to correctly rename the built cpython wheels as ABI3.
  350. repair-wheel-command = "./.ci/scripts/auditwheel_wrapper.py -w {dest_dir} {wheel}"
  351. [tool.cibuildwheel.macos]
  352. # Wrap the repair command to correctly rename the built cpython wheels as ABI3.
  353. repair-wheel-command = "./.ci/scripts/auditwheel_wrapper.py --require-archs {delocate_archs} -w {dest_dir} {wheel}"