Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Do not check lint/test dependencies at runtime. (#8377)
Browse files Browse the repository at this point in the history
moves non-runtime dependencies out of synapse.python_dependencies (test and lint)
  • Loading branch information
clokep committed Sep 23, 2020
1 parent a4e63e5 commit bbde403
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion changelog.d/8330.misc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Move lint-related dependencies to package-extra field, update CONTRIBUTING.md to utilise this.
Move lint-related dependencies to package-extra field, update CONTRIBUTING.md to utilise this.
1 change: 1 addition & 0 deletions changelog.d/8377.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move lint-related dependencies to package-extra field, update CONTRIBUTING.md to utilise this.
16 changes: 16 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,22 @@ 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",
Expand Down
13 changes: 4 additions & 9 deletions synapse/python_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -92,28 +95,20 @@
"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]

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


Expand Down
8 changes: 3 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down Expand Up @@ -36,7 +35,7 @@ setenv =
[testenv]
deps =
{[base]deps}
extras = all
extras = all, test

whitelist_externals =
sh
Expand Down Expand Up @@ -84,7 +83,6 @@ deps =
# Old automat version for Twisted
Automat == 0.3.0

mock
lxml
coverage
coverage-enable-subprocess
Expand All @@ -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:}

Expand Down

0 comments on commit bbde403

Please sign in to comment.