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 547a0c9 commit 59a2446
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/lightning_utilities/core/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,14 @@ def _check_requirement(self) -> None:
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}"
self.available = req.specifier.contains(pkg_version)
except (PackageNotFoundError, InvalidVersion) as ex:
self.available = False
self.message = f"{ex.__class__.__name__}: {ex}. HINT: Try running `pip install -U {self.requirement!r}`"

if self.available:
self.message = f"Requirement {self.requirement!r} met"
else:
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 59a2446

Please sign in to comment.