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

Commit 727b4b0

Browse files
author
David Robertson
committed
Include version in error messages
This will hopefully distinguish between the version of the source code and the version of the distribution package that is installed.
1 parent 572a1f3 commit 727b4b0

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

synapse/util/check_dependencies.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def dependencies(self) -> Iterable[str]:
5757
RUNTIME_EXTRAS = (
5858
set(metadata.metadata(DISTRIBUTION_NAME).get_all("Provides-Extra")) - DEV_EXTRAS
5959
)
60+
VERSION = metadata.version(DISTRIBUTION_NAME)
6061

6162

6263
def _is_dev_dependency(req: Requirement) -> bool:
@@ -105,18 +106,24 @@ def _dependencies_for_extra(extra: str) -> Iterable[Dependency]:
105106

106107
def _not_installed(requirement: Requirement, extra: Optional[str] = None) -> str:
107108
if extra:
108-
return f"Need {requirement.name} for {extra}, but it is not installed"
109+
return f"Synapse {VERSION} needs {requirement.name} for {extra}, " \
110+
f"but it is not installed"
109111
else:
110-
return f"Need {requirement.name}, but it is not installed"
112+
return f"Synapse {VERSION} needs {requirement.name}, but it is not installed"
111113

112114

113115
def _incorrect_version(
114116
requirement: Requirement, got: str, extra: Optional[str] = None
115117
) -> str:
116118
if extra:
117-
return f"Need {requirement} for {extra}, but got {requirement.name}=={got}"
119+
return (
120+
f"Synapse {VERSION} needs {requirement} for {extra}, "
121+
f"but got {requirement.name}=={got}"
122+
)
118123
else:
119-
return f"Need {requirement}, but got {requirement.name}=={got}"
124+
return (
125+
f"Synapse {VERSION} needs {requirement}, but got {requirement.name}=={got}"
126+
)
120127

121128

122129
def check_requirements(extra: Optional[str] = None) -> None:
@@ -141,7 +148,7 @@ def check_requirements(extra: Optional[str] = None) -> None:
141148
elif extra in RUNTIME_EXTRAS:
142149
dependencies = _dependencies_for_extra(extra)
143150
else:
144-
raise ValueError(f"Synapse does not provide the feature '{extra}'")
151+
raise ValueError(f"Synapse {VERSION} does not provide the feature '{extra}'")
145152

146153
deps_unfulfilled = []
147154
errors = []

0 commit comments

Comments
 (0)