Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced package "pkg_resources" with "packaging" #7953

Merged
merged 39 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
77207ad
remove pkg_resources and replace with packaging.version
Saelra Jul 20, 2024
6e1970f
Merge branch 'Project-MONAI:dev' into dev
K-Rilla Jul 24, 2024
94195e9
Merge branch 'Project-MONAI:dev' into dev
K-Rilla Jul 26, 2024
9656e43
Removed comments from pkg_resources
K-Rilla Jul 26, 2024
598f70d
Removed a comment
K-Rilla Jul 26, 2024
ab3ae73
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 26, 2024
967f4ad
updated packaging in setup, utils
dedeepyasai Jul 26, 2024
df38261
Fixing imports
K-Rilla Jul 27, 2024
e0c4d21
Fixing imports
K-Rilla Jul 27, 2024
9dd37f7
Merge branch 'dev' of https://github.com/K-Rilla/MONAI into dev
K-Rilla Jul 27, 2024
6acc718
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 27, 2024
758fd66
Fix DCO
Saelra Jul 27, 2024
6ab46f7
Fix DCO
Saelra Jul 27, 2024
6bbaa86
Merge remote-tracking branch 'origin/dev' into dev
Saelra Jul 27, 2024
2cc0e08
DCO Remediation Commit for Kelvin R <kelvinrbNsc@gmail.com>
K-Rilla Jul 27, 2024
4008495
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 27, 2024
bb22a37
Fixing version
K-Rilla Jul 27, 2024
a27f28a
Merge branch 'dev' of https://github.com/K-Rilla/MONAI into dev
K-Rilla Jul 27, 2024
44035af
Merge branch 'dev' into dev
KumoLiu Jul 31, 2024
084a573
Merge branch 'Project-MONAI:dev' into dev
Saelra Aug 2, 2024
de41c64
Addressed comments, reverted pkging references
ken-ni Aug 2, 2024
e30869d
Merge branch 'Project-MONAI:dev' into dev
Saelra Aug 3, 2024
fe1a415
updating exception packaging, remove packaging from requirement-dev.t…
DuretiShemsi Aug 3, 2024
ed56b7e
DCO Remediation Commit for Dureti <98233210+DuretiShemsi@users.norepl…
DuretiShemsi Aug 3, 2024
e53b5a9
updating exception packaging, remove packaging from requirement-dev.txt
DuretiShemsi Aug 3, 2024
6f5005c
Merge branch 'dev' of github.com:K-Rilla/MONAI into dev
DuretiShemsi Aug 3, 2024
d93374f
fix linting, changed import sub module packaging.version
DuretiShemsi Aug 3, 2024
52cc946
Merge branch 'dev' into dev
KumoLiu Aug 5, 2024
e1e9231
Merge branch 'dev' into dev
ken-ni Aug 7, 2024
25e19a9
Added packaging to requirements-dev.
K-Rilla Aug 7, 2024
6132581
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 7, 2024
cd24d26
Merge branch 'dev' into dev
ken-ni Aug 9, 2024
4041ffe
Remove packaging from requirements-dev
ken-ni Aug 9, 2024
8226d4c
add packaging in pythonapp.yml
KumoLiu Aug 9, 2024
0223751
Merge branch 'dev' into dev
KumoLiu Aug 9, 2024
f8689c8
minor fix
KumoLiu Aug 9, 2024
e3c3490
Revert "minor fix"
KumoLiu Aug 9, 2024
d28e27a
DCO Remediation Commit for YunLiu <55491388+KumoLiu@users.noreply.git…
KumoLiu Aug 9, 2024
640726d
Merge branch 'dev' into dev
KumoLiu Aug 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ onnxruntime; python_version <= '3.10'
zarr
huggingface_hub
pyamg>=5.0.0
packaging
11 changes: 5 additions & 6 deletions monai/utils/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from re import match
from types import FunctionType, ModuleType
from typing import Any, Iterable, cast

import torch

# bundle config system flags
Expand Down Expand Up @@ -564,11 +563,11 @@ def version_leq(lhs: str, rhs: str) -> bool:
"""

lhs, rhs = str(lhs), str(rhs)
pkging, has_ver = optional_import("pkg_resources", name="packaging")
pkging, has_ver = optional_import("packaging")
if has_ver:
try:
return cast(bool, pkging.version.Version(lhs) <= pkging.version.Version(rhs))
except pkging.version.InvalidVersion:
except pkging.version.Version.InvalidVersion:
KumoLiu marked this conversation as resolved.
Show resolved Hide resolved
return True

lhs_, rhs_ = parse_version_strs(lhs, rhs)
Expand All @@ -591,11 +590,11 @@ def version_geq(lhs: str, rhs: str) -> bool:

"""
lhs, rhs = str(lhs), str(rhs)
pkging, has_ver = optional_import("pkg_resources", name="packaging")
pkging, has_ver = optional_import("packaging")
if has_ver:
try:
return cast(bool, pkging.version.Version(lhs) >= pkging.version.Version(rhs))
except pkging.version.InvalidVersion:
except pkging.version.Version.InvalidVersion:
KumoLiu marked this conversation as resolved.
Show resolved Hide resolved
return True

lhs_, rhs_ = parse_version_strs(lhs, rhs)
Expand Down Expand Up @@ -629,7 +628,7 @@ def pytorch_after(major: int, minor: int, patch: int = 0, current_ver_string: st
if current_ver_string is None:
_env_var = os.environ.get("PYTORCH_VER", "")
current_ver_string = _env_var if _env_var else torch.__version__
ver, has_ver = optional_import("pkg_resources", name="parse_version")
ver, has_ver = optional_import("packaging.version", name="parse")
if has_ver:
return ver(".".join((f"{major}", f"{minor}", f"{patch}"))) <= ver(f"{current_ver_string}") # type: ignore
parts = f"{current_ver_string}".split("+", 1)[0].split(".", 3)
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ nvidia-ml-py
huggingface_hub
pyamg>=5.0.0
git+https://github.com/Project-MONAI/GenerativeModels.git@7428fce193771e9564f29b91d29e523dd1b6b4cd
packaging
KumoLiu marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions requirements-min.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ pyyaml =
pyyaml
fire =
fire
packaging =
packaging
jsonschema =
jsonschema
pynrrd =
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import sys
import warnings

import pkg_resources
from packaging import version
from setuptools import find_packages, setup

import versioneer
Expand All @@ -40,7 +40,7 @@

BUILD_CUDA = FORCE_CUDA or (torch.cuda.is_available() and (CUDA_HOME is not None))

_pt_version = pkg_resources.parse_version(torch.__version__).release
_pt_version = version.parse(torch.__version__).release
if _pt_version is None or len(_pt_version) < 3:
raise AssertionError("unknown torch version")
TORCH_VERSION = int(_pt_version[0]) * 10000 + int(_pt_version[1]) * 100 + int(_pt_version[2])
Expand Down
Loading