diff --git a/docs/requirements.txt b/docs/requirements.txt index fe415a07b5..ff94f7b6de 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -41,3 +41,4 @@ onnxruntime; python_version <= '3.10' zarr huggingface_hub pyamg>=5.0.0 +packaging diff --git a/monai/utils/module.py b/monai/utils/module.py index f5ea57be24..747d3a17b9 100644 --- a/monai/utils/module.py +++ b/monai/utils/module.py @@ -30,7 +30,6 @@ import torch import importlib.metadata -from packaging import version # bundle config system flags @@ -567,10 +566,10 @@ def version_leq(lhs: str, rhs: str) -> bool: """ lhs, rhs = str(lhs), str(rhs) - pkging, has_ver = optional_import("packaging", name="packaging") + pkging, has_ver = optional_import("packaging") if has_ver: try: - return cast(bool, version(lhs) <= version(rhs)) + return cast(bool, pkging.version.Version(lhs) <= pkging.version.Version(rhs)) except version.InvalidVersion: return True @@ -594,10 +593,10 @@ def version_geq(lhs: str, rhs: str) -> bool: """ lhs, rhs = str(lhs), str(rhs) - pkging, has_ver = optional_import("packaging", name="packaging") + pkging, has_ver = optional_import("packaging") if has_ver: try: - return cast(bool, version(lhs) >= version(rhs)) + return cast(bool, pkging.version.Version(lhs) >= pkging.version.Version(rhs)) except version.InvalidVersion: return True diff --git a/requirements-dev.txt b/requirements-dev.txt index ced783443e..1a687a6533 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -59,3 +59,4 @@ nvidia-ml-py huggingface_hub pyamg>=5.0.0 git+https://github.com/Project-MONAI/GenerativeModels.git@7428fce193771e9564f29b91d29e523dd1b6b4cd +packaging diff --git a/requirements-min.txt b/requirements-min.txt index a091ef0568..21cf9d5e5c 100644 --- a/requirements-min.txt +++ b/requirements-min.txt @@ -4,3 +4,4 @@ setuptools>=50.3.0,<66.0.0,!=60.6.0 ; python_version < "3.12" setuptools>=70.2.0; python_version >= "3.12" coverage>=5.5 parameterized +packaging diff --git a/setup.cfg b/setup.cfg index 202e7b0e24..dfa94fcfa1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -137,6 +137,8 @@ pyyaml = pyyaml fire = fire +packaging = + packaging jsonschema = jsonschema pynrrd =