Fix deprecation warning for pkg_resources dependency by changing to packaging (#13643)

* Add `packaging` dependency

* Change to use `packaging` dependency

* Auto-format by https://ultralytics.com/actions

---------

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Christopher FieldandUltralyticsAssistant authored and GitHub committed 2025-08-14 10:46:27 +02:00
1 parent 567c66463e
commit 7071317958
3 files changed
+4 -2

No files matched your search

+1
View File
@@ -78,6 +78,7 @@ dependencies = [
"thop>=0.1.1", # FLOPs computation
"pandas>=1.1.4",
"seaborn>=0.11.0", # plotting
"packaging", # general utilities
"ultralytics>=8.2.64"
]
+1
View File
@@ -39,6 +39,7 @@ seaborn>=0.11.0
# openvino-dev>=2023.0 # OpenVINO export
# Deploy ----------------------------------------------------------------------
packaging # Migration of deprecated pkg_resources packages
setuptools>=70.0.0 # Snyk vulnerability fix
# tritonclient[all]~=2.24.0
+2 -2
View File
@@ -28,8 +28,8 @@ from zipfile import ZipFile, is_zipfile
import cv2
import numpy as np
import packaging
import pandas as pd
import pkg_resources as pkg
import torch
import torchvision
import yaml
@@ -425,7 +425,7 @@ def check_python(minimum="3.8.0"):
def check_version(current="0.0.0", minimum="0.0.0", name="version ", pinned=False, hard=False, verbose=False):
"""Checks if the current version meets the minimum required version, exits or warns based on parameters."""
current, minimum = (pkg.parse_version(x) for x in (current, minimum))
current, minimum = (packaging.version.parse(x) for x in (current, minimum))
result = (current == minimum) if pinned else (current >= minimum) # bool
s = f"WARNING ⚠️ {name}{minimum} is required by YOLOv5, but {name}{current} is currently installed" # string
if hard: