From 6b6dd7a13929592f6b58227d955df6c6823151d7 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 22 Sep 2020 14:17:43 -0400 Subject: [PATCH 1/4] Do not check lint/test dependencies at runtime. --- changelog.d/8330.misc | 2 +- changelog.d/8377.misc | 1 + setup.py | 11 +++++++++++ synapse/python_dependencies.py | 13 ++++--------- 4 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 changelog.d/8377.misc diff --git a/changelog.d/8330.misc b/changelog.d/8330.misc index c51370f215d4..fbfdd524730a 100644 --- a/changelog.d/8330.misc +++ b/changelog.d/8330.misc @@ -1 +1 @@ -Move lint-related dependencies to package-extra field, update CONTRIBUTING.md to utilise this. \ No newline at end of file +Move lint-related dependencies to package-extra field, update CONTRIBUTING.md to utilise this. diff --git a/changelog.d/8377.misc b/changelog.d/8377.misc new file mode 100644 index 000000000000..fbfdd524730a --- /dev/null +++ b/changelog.d/8377.misc @@ -0,0 +1 @@ +Move lint-related dependencies to package-extra field, update CONTRIBUTING.md to utilise this. diff --git a/setup.py b/setup.py index 54ddec8f9f59..0d8cf93a1a0f 100755 --- a/setup.py +++ b/setup.py @@ -94,6 +94,17 @@ def exec_file(path_segments): # Make `pip install matrix-synapse[all]` install all the optional dependencies. CONDITIONAL_REQUIREMENTS["all"] = list(ALL_OPTIONAL_REQUIREMENTS) +# Developer dependencies should not get included in "all". +# +# We pin black so that our tests don't start failing on new releases. +CONDITIONAL_REQUIREMENTS["lint"] = ["isort==5.0.3", "black==19.10b0", "flake8-comprehensions", "flake8"] + +# Dependencies which are exclusively required by unit test code. This is +# NOT a list of all modules that are necessary to run the unit tests. +# Tests assume that all optional dependencies are installed. +# +# parameterized_class decorator was introduced in parameterized 0.7.0 +CONDITIONAL_REQUIREMENTS["test"] = ["mock>=2.0", "parameterized>=0.7.0"] setup( name="matrix-synapse", diff --git a/synapse/python_dependencies.py b/synapse/python_dependencies.py index 67f019fd2237..288631477eaf 100644 --- a/synapse/python_dependencies.py +++ b/synapse/python_dependencies.py @@ -37,6 +37,9 @@ # installed when that optional dependency requirement is specified. It is passed # to setup() as extras_require in setup.py # +# Note that these both represent runtime dependencies (and the versions +# installed are checked at runtime). +# # [1] https://pip.pypa.io/en/stable/reference/pip_install/#requirement-specifiers. REQUIREMENTS = [ @@ -92,20 +95,12 @@ "oidc": ["authlib>=0.14.0"], "systemd": ["systemd-python>=231"], "url_preview": ["lxml>=3.5.0"], - # Dependencies which are exclusively required by unit test code. This is - # NOT a list of all modules that are necessary to run the unit tests. - # Tests assume that all optional dependencies are installed. - # - # parameterized_class decorator was introduced in parameterized 0.7.0 - "test": ["mock>=2.0", "parameterized>=0.7.0"], "sentry": ["sentry-sdk>=0.7.2"], "opentracing": ["jaeger-client>=4.0.0", "opentracing>=2.2.0"], "jwt": ["pyjwt>=1.6.4"], # hiredis is not a *strict* dependency, but it makes things much faster. # (if it is not installed, we fall back to slow code.) "redis": ["txredisapi>=1.4.7", "hiredis"], - # We pin black so that our tests don't start failing on new releases. - "lint": ["isort==5.0.3", "black==19.10b0", "flake8-comprehensions", "flake8"], } ALL_OPTIONAL_REQUIREMENTS = set() # type: Set[str] @@ -113,7 +108,7 @@ for name, optional_deps in CONDITIONAL_REQUIREMENTS.items(): # Exclude systemd as it's a system-based requirement. # Exclude lint as it's a dev-based requirement. - if name not in ["systemd", "lint"]: + if name not in ["systemd"]: ALL_OPTIONAL_REQUIREMENTS = set(optional_deps) | ALL_OPTIONAL_REQUIREMENTS From 282f6fec3f58e6d44bffb8129ffcf281623038ee Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 22 Sep 2020 14:46:39 -0400 Subject: [PATCH 2/4] Run black on setup.py --- setup.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0d8cf93a1a0f..926b1bc86fa8 100755 --- a/setup.py +++ b/setup.py @@ -97,7 +97,12 @@ def exec_file(path_segments): # Developer dependencies should not get included in "all". # # We pin black so that our tests don't start failing on new releases. -CONDITIONAL_REQUIREMENTS["lint"] = ["isort==5.0.3", "black==19.10b0", "flake8-comprehensions", "flake8"] +CONDITIONAL_REQUIREMENTS["lint"] = [ + "isort==5.0.3", + "black==19.10b0", + "flake8-comprehensions", + "flake8", +] # Dependencies which are exclusively required by unit test code. This is # NOT a list of all modules that are necessary to run the unit tests. From 71365c424e1ef3ca2fc0493a3cee270ddcfc7e65 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 22 Sep 2020 16:10:27 -0400 Subject: [PATCH 3/4] Try to fix old-deps. --- tox.ini | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tox.ini b/tox.ini index ddcab0198fc2..b6a91a179290 100644 --- a/tox.ini +++ b/tox.ini @@ -2,13 +2,12 @@ envlist = packaging, py35, py36, py37, py38, check_codestyle, check_isort [base] +extras = test deps = - mock python-subunit junitxml coverage coverage-enable-subprocess - parameterized # cyptography 2.2 requires setuptools >= 18.5 # @@ -36,7 +35,7 @@ setenv = [testenv] deps = {[base]deps} -extras = all +extras = all, test whitelist_externals = sh @@ -84,7 +83,6 @@ deps = # Old automat version for Twisted Automat == 0.3.0 - mock lxml coverage coverage-enable-subprocess @@ -97,7 +95,7 @@ commands = /bin/sh -c 'python -m synapse.python_dependencies | sed -e "s/>=/==/g" -e "s/psycopg2==2.6//" -e "s/pyopenssl==16.0.0/pyopenssl==17.0.0/" | xargs -d"\n" pip install' # Install Synapse itself. This won't update any libraries. - pip install -e . + pip install -e ".[test]" {envbindir}/coverage run "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:} @@ -161,11 +159,7 @@ commands= [testenv:mypy] skip_install = True -deps = - {[base]deps} - mypy==0.782 - mypy-zope -extras = all +extras = all, lint commands = mypy # To find all folders that pass mypy you run: From 7575c1ef009607e96f20d9e9a6b8db08d22ea92a Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Tue, 22 Sep 2020 16:21:05 -0400 Subject: [PATCH 4/4] Rollback a change. --- tox.ini | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index b6a91a179290..4d132eff4cab 100644 --- a/tox.ini +++ b/tox.ini @@ -159,7 +159,11 @@ commands= [testenv:mypy] skip_install = True -extras = all, lint +deps = + {[base]deps} + mypy==0.782 + mypy-zope +extras = all commands = mypy # To find all folders that pass mypy you run: