pyproject.toml 15 KB

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