From 88deccb06caabc67d62a30c23995b3a7bddd2712 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Thu, 29 Jun 2023 15:12:13 -0500 Subject: [PATCH 01/11] Drop Python 3.7 support for CI testing --- .ci/scripts/calculate_jobs.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.ci/scripts/calculate_jobs.py b/.ci/scripts/calculate_jobs.py index b41ec0b6e2dc..c2c18b48e3d7 100755 --- a/.ci/scripts/calculate_jobs.py +++ b/.ci/scripts/calculate_jobs.py @@ -29,11 +29,12 @@ def set_output(key: str, value: str): # First calculate the various trial jobs. # -# For each type of test we only run on Py3.7 on PRs +# For PRs, we only run each type of test with the oldest Python version supported (which +# is Python 3.8 right now) trial_sqlite_tests = [ { - "python-version": "3.7", + "python-version": "3.8", "database": "sqlite", "extras": "all", } @@ -46,13 +47,13 @@ def set_output(key: str, value: str): "database": "sqlite", "extras": "all", } - for version in ("3.8", "3.9", "3.10", "3.11") + for version in ("3.9", "3.10", "3.11") ) trial_postgres_tests = [ { - "python-version": "3.7", + "python-version": "3.8", "database": "postgres", "postgres-version": "11", "extras": "all", @@ -71,7 +72,7 @@ def set_output(key: str, value: str): trial_no_extra_tests = [ { - "python-version": "3.7", + "python-version": "3.8", "database": "sqlite", "extras": "", } From 8a0436dd48ac8a0639f249385d90378a0153cbb5 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Thu, 29 Jun 2023 15:19:25 -0500 Subject: [PATCH 02/11] Update various references to Python 3.8 --- .github/workflows/tests.yml | 6 ++--- docker/Dockerfile-dhvirtualenv | 47 +++++++++++++++++----------------- docs/setup/installation.md | 2 +- docs/upgrade.md | 12 +++++++++ synapse/__init__.py | 4 +-- 5 files changed, 42 insertions(+), 29 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6c2298499777..0a01e8298468 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -320,7 +320,7 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: '3.7' + python-version: '3.8' - name: Prepare old deps if: steps.cache-poetry-old-deps.outputs.cache-hit != 'true' @@ -362,7 +362,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["pypy-3.7"] + python-version: ["pypy-3.8"] extras: ["all"] steps: @@ -477,7 +477,7 @@ jobs: strategy: matrix: include: - - python-version: "3.7" + - python-version: "3.8" postgres-version: "11" - python-version: "3.11" diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv index 861129ebc225..180c46838df8 100644 --- a/docker/Dockerfile-dhvirtualenv +++ b/docker/Dockerfile-dhvirtualenv @@ -28,12 +28,12 @@ FROM docker.io/library/${distro} as builder RUN apt-get update -qq -o Acquire::Languages=none RUN env DEBIAN_FRONTEND=noninteractive apt-get install \ - -yqq --no-install-recommends \ - build-essential \ - ca-certificates \ - devscripts \ - equivs \ - wget + -yqq --no-install-recommends \ + build-essential \ + ca-certificates \ + devscripts \ + equivs \ + wget # fetch and unpack the package # We are temporarily using a fork of dh-virtualenv due to an incompatibility with Python 3.11, which ships with @@ -64,6 +64,7 @@ ENV distro ${distro} # Python < 3.7 assumes LANG="C" means ASCII-only and throws on printing unicode # http://bugs.python.org/issue19846 +# TODO: We can possibly remove this now that we don't support Python 3.7 ENV LANG C.UTF-8 # Install the build dependencies @@ -72,23 +73,23 @@ ENV LANG C.UTF-8 # TODO: it would be nice to do that automatically. RUN apt-get update -qq -o Acquire::Languages=none \ && env DEBIAN_FRONTEND=noninteractive apt-get install \ - -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \ - build-essential \ - curl \ - debhelper \ - devscripts \ - libsystemd-dev \ - lsb-release \ - pkg-config \ - python3-dev \ - python3-pip \ - python3-setuptools \ - python3-venv \ - sqlite3 \ - libpq-dev \ - libicu-dev \ - pkg-config \ - xmlsec1 + -yqq --no-install-recommends -o Dpkg::Options::=--force-unsafe-io \ + build-essential \ + curl \ + debhelper \ + devscripts \ + libsystemd-dev \ + lsb-release \ + pkg-config \ + python3-dev \ + python3-pip \ + python3-setuptools \ + python3-venv \ + sqlite3 \ + libpq-dev \ + libicu-dev \ + pkg-config \ + xmlsec1 # Install rust and ensure it's in the PATH ENV RUSTUP_HOME=/rust diff --git a/docs/setup/installation.md b/docs/setup/installation.md index 86e506a3e231..4ca8c6b69786 100644 --- a/docs/setup/installation.md +++ b/docs/setup/installation.md @@ -200,7 +200,7 @@ When following this route please make sure that the [Platform-specific prerequis System requirements: - POSIX-compliant system (tested on Linux & OS X) -- Python 3.7 or later, up to Python 3.11. +- Python 3.8 or later, up to Python 3.11. - At least 1GB of free RAM if you want to join large public rooms like #matrix:matrix.org If building on an uncommon architecture for which pre-built wheels are diff --git a/docs/upgrade.md b/docs/upgrade.md index 4cd38b13932a..384f4010b445 100644 --- a/docs/upgrade.md +++ b/docs/upgrade.md @@ -87,6 +87,18 @@ process, for example: wget https://packages.matrix.org/debian/pool/main/m/matrix-synapse-py3/matrix-synapse-py3_1.3.0+stretch1_amd64.deb dpkg -i matrix-synapse-py3_1.3.0+stretch1_amd64.deb ``` + +# Upgrading to v1.88.0 + +## Minimum supported Python version + +The minimum supported Python version has been increased from v3.7 to v3.8. +You will need Python 3.8 to run Synapse v1.88.0 (due out July 18th, 2023). + +If you use current versions of the Matrix.org-distributed Debian +packages or Docker images, no action is required. + + # Upgrading to v1.86.0 ## Minimum supported Rust version diff --git a/synapse/__init__.py b/synapse/__init__.py index b97ee59f15b6..6c1801862b61 100644 --- a/synapse/__init__.py +++ b/synapse/__init__.py @@ -25,8 +25,8 @@ from synapse.util.stringutils import strtobool # Check that we're not running on an unsupported Python version. -if sys.version_info < (3, 7): - print("Synapse requires Python 3.7 or above.") +if sys.version_info < (3, 8): + print("Synapse requires Python 3.8 or above.") sys.exit(1) # Allow using the asyncio reactor via env var. From 420a8718a81ce6ec836706a845cdcc1a83e4b7d0 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Thu, 29 Jun 2023 15:23:54 -0500 Subject: [PATCH 03/11] Update Python version in `pyproject.toml` and `poetry.lock` --- poetry.lock | 55 ++------------------------------------------------ pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 54 deletions(-) diff --git a/poetry.lock b/poetry.lock index ee19c246f375..5d2f61be5ce0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -41,9 +41,6 @@ files = [ {file = "attrs-23.1.0.tar.gz", hash = "sha256:6279836d581513a26f1bf235f9acd333bc9115683f14f7e8fae46c98fc50e015"}, ] -[package.dependencies] -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} - [package.extras] cov = ["attrs[tests]", "coverage[toml] (>=5.3)"] dev = ["attrs[docs,tests]", "pre-commit"] @@ -190,7 +187,6 @@ packaging = ">=22.0" pathspec = ">=0.9.0" platformdirs = ">=2" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typed-ast = {version = ">=1.4.2", markers = "python_version < \"3.8\" and implementation_name == \"cpython\""} typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""} [package.extras] @@ -412,7 +408,6 @@ files = [ [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} [[package]] name = "click-default-group" @@ -601,7 +596,6 @@ files = [ [package.dependencies] gitdb = ">=4.0.1,<5" -typing-extensions = {version = ">=3.7.4.3", markers = "python_version < \"3.8\""} [[package]] name = "hiredis" @@ -847,7 +841,6 @@ files = [ ] [package.dependencies] -typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} zipp = ">=0.5" [package.extras] @@ -987,11 +980,9 @@ files = [ [package.dependencies] attrs = ">=17.4.0" -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} importlib-resources = {version = ">=1.4.0", markers = "python_version < \"3.9\""} pkgutil-resolve-name = {version = ">=1.3.10", markers = "python_version < \"3.9\""} pyrsistent = ">=0.14.0,<0.17.0 || >0.17.0,<0.17.1 || >0.17.1,<0.17.2 || >0.17.2" -typing-extensions = {version = "*", markers = "python_version < \"3.8\""} [package.extras] format = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3987", "uri-template", "webcolors (>=1.11)"] @@ -1199,7 +1190,6 @@ files = [ [package.dependencies] mdurl = ">=0.1,<1.0" -typing_extensions = {version = ">=3.7.4", markers = "python_version < \"3.8\""} [package.extras] benchmarking = ["psutil", "pytest", "pytest-benchmark"] @@ -1283,7 +1273,6 @@ files = [ [package.dependencies] attrs = "*" -importlib-metadata = {version = ">=1.4", markers = "python_version < \"3.8\""} [package.extras] dev = ["aiounittest", "black (==22.3.0)", "build (==0.8.0)", "flake8 (==4.0.1)", "isort (==5.9.3)", "mypy (==0.910)", "tox", "twine (==4.0.1)", "twisted"] @@ -1459,7 +1448,6 @@ files = [ [package.dependencies] mypy-extensions = ">=0.4.3" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typed-ast = {version = ">=1.4.0,<2", markers = "python_version < \"3.8\""} typing-extensions = ">=3.10" [package.extras] @@ -1721,9 +1709,6 @@ files = [ {file = "platformdirs-3.1.1.tar.gz", hash = "sha256:024996549ee88ec1a9aa99ff7f8fc819bb59e2c3477b410d90a16d32d6e707aa"}, ] -[package.dependencies] -typing-extensions = {version = ">=4.4", markers = "python_version < \"3.8\""} - [package.extras] docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.22,!=1.23.4)"] test = ["appdirs (==1.4.4)", "covdefaults (>=2.2.2)", "pytest (>=7.2.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"] @@ -2060,7 +2045,6 @@ files = [ [package.dependencies] cryptography = ">=3.1" defusedxml = "*" -importlib-metadata = {version = ">=1.7.0", markers = "python_version < \"3.8\""} importlib-resources = {version = "*", markers = "python_version < \"3.9\""} pyopenssl = "*" python-dateutil = "*" @@ -2410,9 +2394,7 @@ files = [ [package.dependencies] canonicaljson = ">=1.0.0" -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} pynacl = ">=0.3.0" -typing-extensions = {version = ">=3.5", markers = "python_version < \"3.8\""} unpaddedbase64 = ">=1.0.1" [package.extras] @@ -2852,39 +2834,6 @@ files = [ six = "*" twisted = "*" -[[package]] -name = "typed-ast" -version = "1.5.4" -description = "a fork of Python 2 and 3 ast modules with type comment support" -optional = false -python-versions = ">=3.6" -files = [ - {file = "typed_ast-1.5.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:669dd0c4167f6f2cd9f57041e03c3c2ebf9063d0757dc89f79ba1daa2bfca9d4"}, - {file = "typed_ast-1.5.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:211260621ab1cd7324e0798d6be953d00b74e0428382991adfddb352252f1d62"}, - {file = "typed_ast-1.5.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:267e3f78697a6c00c689c03db4876dd1efdfea2f251a5ad6555e82a26847b4ac"}, - {file = "typed_ast-1.5.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:c542eeda69212fa10a7ada75e668876fdec5f856cd3d06829e6aa64ad17c8dfe"}, - {file = "typed_ast-1.5.4-cp310-cp310-win_amd64.whl", hash = "sha256:a9916d2bb8865f973824fb47436fa45e1ebf2efd920f2b9f99342cb7fab93f72"}, - {file = "typed_ast-1.5.4-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:79b1e0869db7c830ba6a981d58711c88b6677506e648496b1f64ac7d15633aec"}, - {file = "typed_ast-1.5.4-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a94d55d142c9265f4ea46fab70977a1944ecae359ae867397757d836ea5a3f47"}, - {file = "typed_ast-1.5.4-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:183afdf0ec5b1b211724dfef3d2cad2d767cbefac291f24d69b00546c1837fb6"}, - {file = "typed_ast-1.5.4-cp36-cp36m-win_amd64.whl", hash = "sha256:639c5f0b21776605dd6c9dbe592d5228f021404dafd377e2b7ac046b0349b1a1"}, - {file = "typed_ast-1.5.4-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:cf4afcfac006ece570e32d6fa90ab74a17245b83dfd6655a6f68568098345ff6"}, - {file = "typed_ast-1.5.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ed855bbe3eb3715fca349c80174cfcfd699c2f9de574d40527b8429acae23a66"}, - {file = "typed_ast-1.5.4-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:6778e1b2f81dfc7bc58e4b259363b83d2e509a65198e85d5700dfae4c6c8ff1c"}, - {file = "typed_ast-1.5.4-cp37-cp37m-win_amd64.whl", hash = "sha256:0261195c2062caf107831e92a76764c81227dae162c4f75192c0d489faf751a2"}, - {file = "typed_ast-1.5.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:2efae9db7a8c05ad5547d522e7dbe62c83d838d3906a3716d1478b6c1d61388d"}, - {file = "typed_ast-1.5.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7d5d014b7daa8b0bf2eaef684295acae12b036d79f54178b92a2b6a56f92278f"}, - {file = "typed_ast-1.5.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:370788a63915e82fd6f212865a596a0fefcbb7d408bbbb13dea723d971ed8bdc"}, - {file = "typed_ast-1.5.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:4e964b4ff86550a7a7d56345c7864b18f403f5bd7380edf44a3c1fb4ee7ac6c6"}, - {file = "typed_ast-1.5.4-cp38-cp38-win_amd64.whl", hash = "sha256:683407d92dc953c8a7347119596f0b0e6c55eb98ebebd9b23437501b28dcbb8e"}, - {file = "typed_ast-1.5.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:4879da6c9b73443f97e731b617184a596ac1235fe91f98d279a7af36c796da35"}, - {file = "typed_ast-1.5.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3e123d878ba170397916557d31c8f589951e353cc95fb7f24f6bb69adc1a8a97"}, - {file = "typed_ast-1.5.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ebd9d7f80ccf7a82ac5f88c521115cc55d84e35bf8b446fcd7836eb6b98929a3"}, - {file = "typed_ast-1.5.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98f80dee3c03455e92796b58b98ff6ca0b2a6f652120c263efdba4d6c5e58f72"}, - {file = "typed_ast-1.5.4-cp39-cp39-win_amd64.whl", hash = "sha256:0fdbcf2fef0ca421a3f5912555804296f0b0960f0418c440f5d6d3abb549f3e1"}, - {file = "typed_ast-1.5.4.tar.gz", hash = "sha256:39e21ceb7388e4bb37f4c679d72707ed46c2fbf2a5609b8b8ebc4b067d977df2"}, -] - [[package]] name = "types-bleach" version = "6.0.0.3" @@ -3293,5 +3242,5 @@ user-search = ["pyicu"] [metadata] lock-version = "2.0" -python-versions = "^3.7.1" -content-hash = "7f31754a1009d7b6c9a1bd7221a0b243ffd510f362c28f0da417aaac16757a87" +python-versions = "^3.8.0" +content-hash = "acf4c4ab961cd4b2833c455330ab214fa6e22435f4076469eafd456dec2e12b2" diff --git a/pyproject.toml b/pyproject.toml index fc47b1ef7101..86ea19e3b6cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -147,7 +147,7 @@ synapse_review_recent_signups = "synapse._scripts.review_recent_signups:main" update_synapse_database = "synapse._scripts.update_synapse_database:main" [tool.poetry.dependencies] -python = "^3.7.1" +python = "^3.8.0" # Mandatory Dependencies # ---------------------- From e0f562c213987fe5c272a76c1d0a21a3c3a32e8c Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Thu, 29 Jun 2023 15:26:02 -0500 Subject: [PATCH 04/11] Add changelog --- changelog.d/15851.removal | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/15851.removal diff --git a/changelog.d/15851.removal b/changelog.d/15851.removal new file mode 100644 index 000000000000..e08df4c1366a --- /dev/null +++ b/changelog.d/15851.removal @@ -0,0 +1 @@ +Remove support for Python 3.7. From 95d2d05d844987d06b027ee1156210cb2965198f Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Thu, 29 Jun 2023 15:47:47 -0500 Subject: [PATCH 05/11] This defaults to UTF-8 in Python3.7+ See https://github.com/matrix-org/synapse/pull/15851#discussion_r1247157000 --- docker/Dockerfile-dhvirtualenv | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv index 180c46838df8..b7679924c24a 100644 --- a/docker/Dockerfile-dhvirtualenv +++ b/docker/Dockerfile-dhvirtualenv @@ -62,11 +62,6 @@ FROM docker.io/library/${distro} ARG distro="" ENV distro ${distro} -# Python < 3.7 assumes LANG="C" means ASCII-only and throws on printing unicode -# http://bugs.python.org/issue19846 -# TODO: We can possibly remove this now that we don't support Python 3.7 -ENV LANG C.UTF-8 - # Install the build dependencies # # NB: keep this list in sync with the list of build-deps in debian/control From d403bcca77948aab47872f744dbdde84394e0a58 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Thu, 29 Jun 2023 16:07:39 -0500 Subject: [PATCH 06/11] Remove importlib_metadata --- pyproject.toml | 121 ++++++++++++++--------------- synapse/util/check_dependencies.py | 5 +- tests/metrics/test_metrics.py | 10 +-- 3 files changed, 63 insertions(+), 73 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 86ea19e3b6cf..4fcfcf84a8b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,38 +1,38 @@ [tool.towncrier] - package = "synapse" - filename = "CHANGES.md" - directory = "changelog.d" - issue_format = "[\\#{issue}](https://github.com/matrix-org/synapse/issues/{issue})" - - [[tool.towncrier.type]] - directory = "feature" - name = "Features" - showcontent = true - - [[tool.towncrier.type]] - directory = "bugfix" - name = "Bugfixes" - showcontent = true - - [[tool.towncrier.type]] - directory = "docker" - name = "Updates to the Docker image" - showcontent = true - - [[tool.towncrier.type]] - directory = "doc" - name = "Improved Documentation" - showcontent = true - - [[tool.towncrier.type]] - directory = "removal" - name = "Deprecations and Removals" - showcontent = true - - [[tool.towncrier.type]] - directory = "misc" - name = "Internal Changes" - showcontent = true +package = "synapse" +filename = "CHANGES.md" +directory = "changelog.d" +issue_format = "[\\#{issue}](https://github.com/matrix-org/synapse/issues/{issue})" + +[[tool.towncrier.type]] +directory = "feature" +name = "Features" +showcontent = true + +[[tool.towncrier.type]] +directory = "bugfix" +name = "Bugfixes" +showcontent = true + +[[tool.towncrier.type]] +directory = "docker" +name = "Updates to the Docker image" +showcontent = true + +[[tool.towncrier.type]] +directory = "doc" +name = "Improved Documentation" +showcontent = true + +[[tool.towncrier.type]] +directory = "removal" +name = "Deprecations and Removals" +showcontent = true + +[[tool.towncrier.type]] +directory = "misc" +name = "Internal Changes" +showcontent = true [tool.black] target-version = ['py37', 'py38', 'py39', 'py310'] @@ -53,13 +53,7 @@ line-length = 88 # B019: Use of functools.lru_cache or functools.cache on methods can lead to memory leaks # B023: Functions defined inside a loop must not use variables redefined in the loop # B024: Abstract base class with no abstract method. -ignore = [ - "B019", - "B023", - "B024", - "E501", - "E731", -] +ignore = ["B019", "B023", "B024", "E501", "E731"] select = [ # pycodestyle checks. "E", @@ -74,7 +68,15 @@ select = [ [tool.isort] line_length = 88 -sections = ["FUTURE", "STDLIB", "THIRDPARTY", "TWISTED", "FIRSTPARTY", "TESTS", "LOCALFOLDER"] +sections = [ + "FUTURE", + "STDLIB", + "THIRDPARTY", + "TWISTED", + "FIRSTPARTY", + "TESTS", + "LOCALFOLDER", +] default_section = "THIRDPARTY" known_first_party = ["synapse"] known_tests = ["tests"] @@ -95,9 +97,7 @@ authors = ["Matrix.org Team and Contributors "] license = "Apache-2.0" readme = "README.rst" repository = "https://github.com/matrix-org/synapse" -packages = [ - { include = "synapse" }, -] +packages = [{ include = "synapse" }] classifiers = [ "Development Status :: 5 - Production/Stable", "Topic :: Communications :: Chat", @@ -113,7 +113,7 @@ include = [ { path = "INSTALL.md", format = "sdist" }, { path = "mypy.ini", format = "sdist" }, { path = "scripts-dev", format = "sdist" }, - { path = "synmark", format="sdist" }, + { path = "synmark", format = "sdist" }, { path = "sytest-blacklist", format = "sdist" }, { path = "tests", format = "sdist" }, { path = "UPGRADE.rst", format = "sdist" }, @@ -123,9 +123,7 @@ include = [ { path = "rust/build.rs", format = "sdist" }, { path = "rust/src/**", format = "sdist" }, ] -exclude = [ - { path = "synapse/*.so", format = "sdist"} -] +exclude = [{ path = "synapse/*.so", format = "sdist" }] [tool.poetry.build] script = "build_rust.py" @@ -166,7 +164,7 @@ signedjson = "^1.1.0" service-identity = ">=18.1.0" # Twisted 18.9 introduces some logger improvements that the structured # logger utilises -Twisted = {extras = ["tls"], version = ">=18.9.0"} +Twisted = { extras = ["tls"], version = ">=18.9.0" } treq = ">=15.1" # Twisted has required pyopenssl 16.0 since about Twisted 16.6. pyOpenSSL = ">=16.0.0" @@ -203,9 +201,6 @@ ijson = ">=3.1.4" matrix-common = "^1.3.0" # We need packaging.requirements.Requirement, added in 16.1. packaging = ">=16.1" -# At the time of writing, we only use functions from the version `importlib.metadata` -# which shipped in Python 3.8. This corresponds to version 1.4 of the backport. -importlib_metadata = { version = ">=1.4", python = "<3.8" } # This is the most recent version of Pydantic with available on common distros. pydantic = ">=1.7.4" @@ -285,7 +280,9 @@ all = [ # matrix-synapse-ldap3 "matrix-synapse-ldap3", # postgres - "psycopg2", "psycopg2cffi", "psycopg2cffi-compat", + "psycopg2", + "psycopg2cffi", + "psycopg2cffi-compat", # saml2 "pysaml2", # oidc and jwt @@ -295,9 +292,11 @@ all = [ # sentry "sentry-sdk", # opentracing - "jaeger-client", "opentracing", + "jaeger-client", + "opentracing", # redis - "txredisapi", "hiredis", + "txredisapi", + "hiredis", # cache-memory "pympler", # improved user search @@ -357,9 +356,9 @@ tomli = ">=1.2.3" optional = true [tool.poetry.group.dev-docs.dependencies] -sphinx = {version = "^6.1", python = "^3.8"} -sphinx-autodoc2 = {version = "^0.4.2", python = "^3.8"} -myst-parser = {version = "^1.0.0", python = "^3.8"} +sphinx = { version = "^6.1", python = "^3.8" } +sphinx-autodoc2 = { version = "^0.4.2", python = "^3.8" } +myst-parser = { version = "^1.0.0", python = "^3.8" } furo = ">=2022.12.7,<2024.0.0" @@ -378,8 +377,8 @@ build-backend = "poetry.core.masonry.api" skip = "cp36* *-musllinux_i686 pp*aarch64 *-musllinux_aarch64" # We need a rust compiler -before-all = "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y --profile minimal" -environment= { PATH = "$PATH:$HOME/.cargo/bin" } +before-all = "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y --profile minimal" +environment = { PATH = "$PATH:$HOME/.cargo/bin" } # For some reason if we don't manually clean the build directory we # can end up polluting the next build with a .so that is for the wrong diff --git a/synapse/util/check_dependencies.py b/synapse/util/check_dependencies.py index 1c0fde4966e7..114130a08fe2 100644 --- a/synapse/util/check_dependencies.py +++ b/synapse/util/check_dependencies.py @@ -21,16 +21,13 @@ """ import logging +from importlib import metadata from typing import Iterable, NamedTuple, Optional from packaging.requirements import Requirement DISTRIBUTION_NAME = "matrix-synapse" -try: - from importlib import metadata -except ImportError: - import importlib_metadata as metadata # type: ignore[no-redef] __all__ = ["check_requirements"] diff --git a/tests/metrics/test_metrics.py b/tests/metrics/test_metrics.py index 7c3656d049f1..d14876826ce9 100644 --- a/tests/metrics/test_metrics.py +++ b/tests/metrics/test_metrics.py @@ -12,19 +12,13 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from importlib import metadata from typing import Dict, Tuple - -from typing_extensions import Protocol - -try: - from importlib import metadata -except ImportError: - import importlib_metadata as metadata # type: ignore[no-redef] - from unittest.mock import patch from pkg_resources import parse_version from prometheus_client.core import Sample +from typing_extensions import Protocol from synapse.app._base import _set_prometheus_client_use_created_metrics from synapse.metrics import REGISTRY, InFlightGauge, generate_latest From b5939ff4b86fc12dd6c848cefcd6fa8d5a245d4f Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Thu, 29 Jun 2023 16:08:03 -0500 Subject: [PATCH 07/11] Update lockfile --- poetry.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/poetry.lock b/poetry.lock index 5d2f61be5ce0..7f0abff3138c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3243,4 +3243,4 @@ user-search = ["pyicu"] [metadata] lock-version = "2.0" python-versions = "^3.8.0" -content-hash = "acf4c4ab961cd4b2833c455330ab214fa6e22435f4076469eafd456dec2e12b2" +content-hash = "0832381cc9e7065e8d95c810d732aa031b98d55cf188719989b12d841993e62e" From d11f71c0b8aa6822992bc6c1ddcb1a694f07ad61 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Thu, 29 Jun 2023 16:08:56 -0500 Subject: [PATCH 08/11] Save without formatting --- pyproject.toml | 118 ++++++++++++++++++++++++------------------------- 1 file changed, 58 insertions(+), 60 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4fcfcf84a8b4..d24c6507de1a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,38 +1,38 @@ [tool.towncrier] -package = "synapse" -filename = "CHANGES.md" -directory = "changelog.d" -issue_format = "[\\#{issue}](https://github.com/matrix-org/synapse/issues/{issue})" - -[[tool.towncrier.type]] -directory = "feature" -name = "Features" -showcontent = true - -[[tool.towncrier.type]] -directory = "bugfix" -name = "Bugfixes" -showcontent = true - -[[tool.towncrier.type]] -directory = "docker" -name = "Updates to the Docker image" -showcontent = true - -[[tool.towncrier.type]] -directory = "doc" -name = "Improved Documentation" -showcontent = true - -[[tool.towncrier.type]] -directory = "removal" -name = "Deprecations and Removals" -showcontent = true - -[[tool.towncrier.type]] -directory = "misc" -name = "Internal Changes" -showcontent = true + package = "synapse" + filename = "CHANGES.md" + directory = "changelog.d" + issue_format = "[\\#{issue}](https://github.com/matrix-org/synapse/issues/{issue})" + + [[tool.towncrier.type]] + directory = "feature" + name = "Features" + showcontent = true + + [[tool.towncrier.type]] + directory = "bugfix" + name = "Bugfixes" + showcontent = true + + [[tool.towncrier.type]] + directory = "docker" + name = "Updates to the Docker image" + showcontent = true + + [[tool.towncrier.type]] + directory = "doc" + name = "Improved Documentation" + showcontent = true + + [[tool.towncrier.type]] + directory = "removal" + name = "Deprecations and Removals" + showcontent = true + + [[tool.towncrier.type]] + directory = "misc" + name = "Internal Changes" + showcontent = true [tool.black] target-version = ['py37', 'py38', 'py39', 'py310'] @@ -53,7 +53,13 @@ line-length = 88 # B019: Use of functools.lru_cache or functools.cache on methods can lead to memory leaks # B023: Functions defined inside a loop must not use variables redefined in the loop # B024: Abstract base class with no abstract method. -ignore = ["B019", "B023", "B024", "E501", "E731"] +ignore = [ + "B019", + "B023", + "B024", + "E501", + "E731", +] select = [ # pycodestyle checks. "E", @@ -68,15 +74,7 @@ select = [ [tool.isort] line_length = 88 -sections = [ - "FUTURE", - "STDLIB", - "THIRDPARTY", - "TWISTED", - "FIRSTPARTY", - "TESTS", - "LOCALFOLDER", -] +sections = ["FUTURE", "STDLIB", "THIRDPARTY", "TWISTED", "FIRSTPARTY", "TESTS", "LOCALFOLDER"] default_section = "THIRDPARTY" known_first_party = ["synapse"] known_tests = ["tests"] @@ -97,7 +95,9 @@ authors = ["Matrix.org Team and Contributors "] license = "Apache-2.0" readme = "README.rst" repository = "https://github.com/matrix-org/synapse" -packages = [{ include = "synapse" }] +packages = [ + { include = "synapse" }, +] classifiers = [ "Development Status :: 5 - Production/Stable", "Topic :: Communications :: Chat", @@ -113,7 +113,7 @@ include = [ { path = "INSTALL.md", format = "sdist" }, { path = "mypy.ini", format = "sdist" }, { path = "scripts-dev", format = "sdist" }, - { path = "synmark", format = "sdist" }, + { path = "synmark", format="sdist" }, { path = "sytest-blacklist", format = "sdist" }, { path = "tests", format = "sdist" }, { path = "UPGRADE.rst", format = "sdist" }, @@ -123,7 +123,9 @@ include = [ { path = "rust/build.rs", format = "sdist" }, { path = "rust/src/**", format = "sdist" }, ] -exclude = [{ path = "synapse/*.so", format = "sdist" }] +exclude = [ + { path = "synapse/*.so", format = "sdist"} +] [tool.poetry.build] script = "build_rust.py" @@ -164,7 +166,7 @@ signedjson = "^1.1.0" service-identity = ">=18.1.0" # Twisted 18.9 introduces some logger improvements that the structured # logger utilises -Twisted = { extras = ["tls"], version = ">=18.9.0" } +Twisted = {extras = ["tls"], version = ">=18.9.0"} treq = ">=15.1" # Twisted has required pyopenssl 16.0 since about Twisted 16.6. pyOpenSSL = ">=16.0.0" @@ -280,9 +282,7 @@ all = [ # matrix-synapse-ldap3 "matrix-synapse-ldap3", # postgres - "psycopg2", - "psycopg2cffi", - "psycopg2cffi-compat", + "psycopg2", "psycopg2cffi", "psycopg2cffi-compat", # saml2 "pysaml2", # oidc and jwt @@ -292,11 +292,9 @@ all = [ # sentry "sentry-sdk", # opentracing - "jaeger-client", - "opentracing", + "jaeger-client", "opentracing", # redis - "txredisapi", - "hiredis", + "txredisapi", "hiredis", # cache-memory "pympler", # improved user search @@ -356,9 +354,9 @@ tomli = ">=1.2.3" optional = true [tool.poetry.group.dev-docs.dependencies] -sphinx = { version = "^6.1", python = "^3.8" } -sphinx-autodoc2 = { version = "^0.4.2", python = "^3.8" } -myst-parser = { version = "^1.0.0", python = "^3.8" } +sphinx = {version = "^6.1", python = "^3.8"} +sphinx-autodoc2 = {version = "^0.4.2", python = "^3.8"} +myst-parser = {version = "^1.0.0", python = "^3.8"} furo = ">=2022.12.7,<2024.0.0" @@ -377,8 +375,8 @@ build-backend = "poetry.core.masonry.api" skip = "cp36* *-musllinux_i686 pp*aarch64 *-musllinux_aarch64" # We need a rust compiler -before-all = "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y --profile minimal" -environment = { PATH = "$PATH:$HOME/.cargo/bin" } +before-all = "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y --profile minimal" +environment= { PATH = "$PATH:$HOME/.cargo/bin" } # For some reason if we don't manually clean the build directory we # can end up polluting the next build with a .so that is for the wrong From 6ac7044d394173c181ed74e207905651762c26cc Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Thu, 29 Jun 2023 23:06:31 -0500 Subject: [PATCH 09/11] Use minimum supported Python 3.8 over default x-range which points to Python 3.7 See https://github.com/matrix-org/synapse/pull/15851#discussion_r1247395557 --- .github/workflows/release-artifacts.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index 09812004017f..c84a2e308408 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -30,7 +30,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.x' + python-version: '3.8' - id: set-distros run: | # if we're running from a tag, get the full list of distros; otherwise just use debian:sid @@ -76,7 +76,7 @@ jobs: - name: Set up python uses: actions/setup-python@v4 with: - python-version: '3.x' + python-version: '3.8' - name: Build the packages # see https://github.com/docker/build-push-action/issues/252 @@ -125,9 +125,10 @@ jobs: - uses: actions/setup-python@v4 with: - # setup-python@v4 doesn't impose a default python version. Need to use 3.x - # here, because `python` on osx points to Python 2.7. - python-version: "3.x" + # setup-python@v4 doesn't impose a default python version. We define a version + # here because `python` on osx points to Python 2.7. We use the minimium + # supported Python version that Synapse supports. + python-version: "3.8" - name: Install cibuildwheel run: python -m pip install cibuildwheel==2.9.0 From 3d5a9f40cffb57204707a7448fab29527d1f768f Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 30 Jun 2023 00:36:04 -0500 Subject: [PATCH 10/11] Use cp38 --- .github/workflows/release-artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index c84a2e308408..35c3ca5848dc 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -145,7 +145,7 @@ jobs: - name: Only build a single wheel on PR if: startsWith(github.ref, 'refs/pull/') - run: echo "CIBW_BUILD="cp37-manylinux_${{ matrix.arch }}"" >> $GITHUB_ENV + run: echo "CIBW_BUILD="cp38-manylinux_${{ matrix.arch }}"" >> $GITHUB_ENV - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse From 6e579cbe559136b38c1e8c8c42376bc5daac72a1 Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 30 Jun 2023 02:06:37 -0500 Subject: [PATCH 11/11] Try with 3.x again after using cp38 --- .github/workflows/release-artifacts.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index 35c3ca5848dc..f331f67d9728 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -30,7 +30,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.8' + python-version: '3.x' - id: set-distros run: | # if we're running from a tag, get the full list of distros; otherwise just use debian:sid @@ -76,7 +76,7 @@ jobs: - name: Set up python uses: actions/setup-python@v4 with: - python-version: '3.8' + python-version: '3.x' - name: Build the packages # see https://github.com/docker/build-push-action/issues/252 @@ -125,10 +125,9 @@ jobs: - uses: actions/setup-python@v4 with: - # setup-python@v4 doesn't impose a default python version. We define a version - # here because `python` on osx points to Python 2.7. We use the minimium - # supported Python version that Synapse supports. - python-version: "3.8" + # setup-python@v4 doesn't impose a default python version. Need to use 3.x + # here, because `python` on osx points to Python 2.7. + python-version: "3.x" - name: Install cibuildwheel run: python -m pip install cibuildwheel==2.9.0