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

Commit 2eef234

Browse files
authored
Fix a bug introduced in 1.54.0rc1 which meant that Synapse would refuse to start if pre-release versions of dependencies were installed. (#12177)
* Add failing test to characterise the regression #12176 * Permit pre-release versions of specified packages * Newsfile (bugfix) Signed-off-by: Olivier Wilkinson (reivilibre) <[email protected]>
1 parent d2ef1a7 commit 2eef234

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

changelog.d/12177.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug introduced in 1.54.0rc1 which meant that Synapse would refuse to start if pre-release versions of dependencies were installed.

synapse/util/check_dependencies.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ def check_requirements(extra: Optional[str] = None) -> None:
163163
deps_unfulfilled.append(requirement.name)
164164
errors.append(_not_installed(requirement, extra))
165165
else:
166-
if not requirement.specifier.contains(dist.version):
166+
# We specify prereleases=True to allow prereleases such as RCs.
167+
if not requirement.specifier.contains(dist.version, prereleases=True):
167168
deps_unfulfilled.append(requirement.name)
168169
errors.append(_incorrect_version(requirement, dist.version, extra))
169170

tests/util/test_check_dependencies.py

+19
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def read_text(self, filename):
2727

2828

2929
old = DummyDistribution("0.1.2")
30+
old_release_candidate = DummyDistribution("0.1.2rc3")
3031
new = DummyDistribution("1.2.3")
32+
new_release_candidate = DummyDistribution("1.2.3rc4")
3133

3234
# could probably use stdlib TestCase --- no need for twisted here
3335

@@ -110,3 +112,20 @@ def test_check_for_extra_dependencies(self) -> None:
110112
with self.mock_installed_package(new):
111113
# should not raise
112114
check_requirements("cool-extra")
115+
116+
def test_release_candidates_satisfy_dependency(self) -> None:
117+
"""
118+
Tests that release candidates count as far as satisfying a dependency
119+
is concerned.
120+
(Regression test, see #12176.)
121+
"""
122+
with patch(
123+
"synapse.util.check_dependencies.metadata.requires",
124+
return_value=["dummypkg >= 1"],
125+
):
126+
with self.mock_installed_package(old_release_candidate):
127+
self.assertRaises(DependencyException, check_requirements)
128+
129+
with self.mock_installed_package(new_release_candidate):
130+
# should not raise
131+
check_requirements()

0 commit comments

Comments
 (0)