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

Commit 82f75cc

Browse files
committed
appease the test gods
1 parent 23d6fbe commit 82f75cc

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

synapse/config/server.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,15 @@ def _warn_if_webclient_configured(listeners):
471471

472472

473473
KNOWN_RESOURCES = (
474-
'client', 'consent', 'federation', 'keys', 'media', 'metrics', 'static', 'webclient',
474+
'client',
475+
'consent',
476+
'federation',
477+
'keys',
478+
'media',
479+
'metrics',
480+
'replication',
481+
'static',
482+
'webclient',
475483
)
476484

477485

synapse/python_dependencies.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616

1717
import logging
1818

19-
from pkg_resources import DistributionNotFound, VersionConflict, get_distribution
19+
from pkg_resources import (
20+
DistributionNotFound,
21+
Requirement,
22+
VersionConflict,
23+
get_distribution,
24+
)
2025

2126
logger = logging.getLogger(__name__)
2227

@@ -79,11 +84,35 @@
7984

8085

8186
def list_requirements():
82-
deps = set(REQUIREMENTS)
83-
for opt in CONDITIONAL_REQUIREMENTS.values():
84-
deps = set(opt) | deps
85-
86-
return list(deps)
87+
# map from project_name to list of specs
88+
deps = {}
89+
for req in REQUIREMENTS + [
90+
o for opt in CONDITIONAL_REQUIREMENTS.values() for o in opt
91+
]:
92+
dist = Requirement.parse(req)
93+
deps.setdefault(dist.project_name, []).extend(dist.specs)
94+
95+
for proj, specs in deps.items():
96+
# re-parse the requirement, to sort by version
97+
req = proj + ",".join(s[0] + s[1] for s in specs)
98+
req = Requirement.parse(req)
99+
100+
# flatten to the most constrained version for each specifier.
101+
specs_by_op = {}
102+
for op, ver in specs:
103+
# if there are multiple '>=' requirements, take the last
104+
if op in (">=", ">"):
105+
specs_by_op[op] = ver
106+
107+
# if there are multiple '<' requirements, take the first
108+
elif op in ("<=", "<"):
109+
if op not in specs_by_op:
110+
specs_by_op[op] = ver
111+
112+
else:
113+
raise Exception("Unknown requirement op " + op)
114+
115+
yield proj + ",".join(op + ver for op, ver in specs_by_op.items())
87116

88117

89118
class DependencyException(Exception):

0 commit comments

Comments
 (0)