Skip to content

Commit

Permalink
Handle missing packages in version checking
Browse files Browse the repository at this point in the history
  • Loading branch information
dcamron committed Jun 28, 2024
1 parent 0b19d67 commit 046c8c8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/metpy/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""
import contextlib
import functools
from importlib.metadata import requires, version
from importlib.metadata import PackageNotFoundError, requires, version
import operator as op
import re

Expand Down Expand Up @@ -55,7 +55,12 @@ def version_check(version_spec):
metadata_spec = _get_metadata_spec(module_name)
_, _, minimum_version_number = _parse_version_spec(metadata_spec)

installed_version = Version(version(module_name))
try:
installed_version = Version(version(module_name))
except PackageNotFoundError:
# Package not installed considered false condition for spec
return False

specified_version = Version(version_number)
minimum_version = Version(minimum_version_number)

Expand Down

0 comments on commit 046c8c8

Please sign in to comment.