pyproject.toml 15 KB

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