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

Commit

Permalink
Include version in error messages
Browse files Browse the repository at this point in the history
This will hopefully distinguish between the version of the source code
and the version of the distribution package that is installed.
  • Loading branch information
David Robertson committed Mar 3, 2022
1 parent 572a1f3 commit 727b4b0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions synapse/util/check_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def dependencies(self) -> Iterable[str]:
RUNTIME_EXTRAS = (
set(metadata.metadata(DISTRIBUTION_NAME).get_all("Provides-Extra")) - DEV_EXTRAS
)
VERSION = metadata.version(DISTRIBUTION_NAME)


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

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


def _incorrect_version(
requirement: Requirement, got: str, extra: Optional[str] = None
) -> str:
if extra:
return f"Need {requirement} for {extra}, but got {requirement.name}=={got}"
return (
f"Synapse {VERSION} needs {requirement} for {extra}, "
f"but got {requirement.name}=={got}"
)
else:
return f"Need {requirement}, but got {requirement.name}=={got}"
return (
f"Synapse {VERSION} needs {requirement}, but got {requirement.name}=={got}"
)


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

deps_unfulfilled = []
errors = []
Expand Down

0 comments on commit 727b4b0

Please sign in to comment.