Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
awaelchli committed Jul 13, 2024
1 parent e00b552 commit 547a0c9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lightning_utilities/core/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,18 @@ def __init__(self, requirement: Optional[str] = None, module: Optional[str] = No

def _check_requirement(self) -> None:
assert self.requirement # noqa: S101; needed for typing
req = Requirement(self.requirement)
try:
req = Requirement(self.requirement)
pkg_version = Version(_version(req.name))
if req.specifier.contains(pkg_version):
self.available = True
self.message = f"Requirement {self.requirement!r} met"
else:
self.available = False
self.message = f"Requirement {self.requirement!r} not met. Current version: {pkg_version}"
except (PackageNotFoundError, InvalidVersion):
except (PackageNotFoundError, InvalidVersion) as ex:
self.available = False
self.message = f"Package not found: {req.name}. HINT: Try running `pip install -U {self.requirement!r}`"
self.message = f"{ex.__class__.__name__}: {ex}. HINT: Try running `pip install -U {self.requirement!r}`"
req_include_version = any(c in self.requirement for c in "=<>")
if not req_include_version or self.module is not None:
module = self.requirement if self.module is None else self.module
Expand Down

0 comments on commit 547a0c9

Please sign in to comment.