Skip to content

Replace pkg_resources with packaging#13707

Merged
Laughing-q merged 1 commit intomasterfrom
parse-version-fix
Feb 9, 2026
Merged

Replace pkg_resources with packaging#13707
Laughing-q merged 1 commit intomasterfrom
parse-version-fix

Conversation

@Y-T-G
Copy link
Copy Markdown
Contributor

@Y-T-G Y-T-G commented Feb 9, 2026

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Replaces pkg_resources version checks with packaging.version.parse for Weights & Biases (W&B) login gating in YOLOv5 logging 🔧📈

📊 Key Changes

  • Swapped import pkg_resources as pkgfrom packaging.version import parse
  • Updated the W&B version comparison logic to use parse(wandb.__version__) >= parse("0.12.2")
  • Kept existing behavior: only attempts wandb.login() when running on primary ranks (RANK in {0, -1}) 🚦

🎯 Purpose & Impact

  • Reduces reliance on pkg_resources (often considered heavier and increasingly discouraged) ➜ cleaner dependency usage 🧹
  • Improves compatibility and reliability of version parsing/comparisons for W&B 🧩
  • Minimal user-facing change: logging behavior should remain the same, but environments without pkg_resources quirks are less likely to hit import/version issues ✅

Signed-off-by: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com>
@UltralyticsAssistant UltralyticsAssistant added dependencies Dependencies and packages python Pull requests that update python code labels Feb 9, 2026
@UltralyticsAssistant
Copy link
Copy Markdown
Member

👋 Hello @Y-T-G, thank you for submitting a ultralytics/yolov5 🚀 PR! To ensure a seamless integration of your work, please review the following checklist:

-✅ Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
-✅ Synchronize with Source: Confirm your PR is synchronized with the ultralytics/yolov5 main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
-✅ Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
-✅ Update Documentation: Update the relevant documentation for any new or modified features.
-✅ Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
-✅ Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
-✅ Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

For more guidance, please refer to our Contributing Guide. This is an automated message 🤖—an Ultralytics engineer will assist soon. If you have any questions, feel free to comment here 🚀

Copy link
Copy Markdown
Member

@UltralyticsAssistant UltralyticsAssistant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 PR Review

Made with ❤️ by Ultralytics Actions

PR looks clean. The switch to packaging.version.parse appears behavior-neutral and no issues are evident in this diff.

@Laughing-q Laughing-q merged commit 3fb1111 into master Feb 9, 2026
12 of 14 checks passed
@Laughing-q Laughing-q deleted the parse-version-fix branch February 9, 2026 12:38
@UltralyticsAssistant
Copy link
Copy Markdown
Member

Merged — huge thanks for the thoughtful improvement here, @Y-T-G! 🙌

As Leonardo da Vinci said, “Simplicity is the ultimate sophistication.” This PR is a perfect example: swapping out the heavier pkg_resources approach for packaging.version.parse keeps YOLOv5’s W&B login gating cleaner, more reliable across environments, and easier to maintain—while preserving the exact rank-safe behavior (RANK in {0, -1}).

Really appreciate you taking the time to refine the details that make the whole project smoother for everyone. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Dependencies and packages python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants