[PR #5078] fix: remove direct use of importlib.metadata for version access (issue #5040) #4219

Closed
opened 2026-02-20 17:49:51 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/5078

State: closed
Merged: No


Fix importlib.metadata version detection issue

Related Issue

  • Fixes #5040 - Issue with importlib.metadata version detection

Changes

  • Modified version detection in libs/cli/generate_schema.py to use direct module version access
  • Updated libs/checkpoint/langgraph/store/base/embed.py to implement a more robust version detection system:
    • Primary method: Direct access to module's __version__ attribute
    • Fallback method: importlib.metadata version detection
    • Improved error messages with version information

Implementation Details

The changes implement a two-step version detection process:

  1. First attempts to get version directly from the module's __version__ attribute
  2. Falls back to importlib.metadata if direct access fails
  3. Provides clear error messages about version detection failures

Testing

  • Verified that schema generation works correctly with the new version detection logic
  • Confirmed that all tests pass with the new implementation
  • Tested both successful and failure scenarios for version detection

Notes

  • This change makes version detection more resilient while maintaining backward compatibility
  • The implementation is compatible with uv's versioning approach
  • No breaking changes to existing functionality

Concerns

None - The changes are backward compatible and maintain existing functionality while improving reliability.

Additional Context

This fix addresses the issue where importlib.metadata version detection could fail in certain environments. The new implementation provides a more robust solution that works across different Python environments and package management systems.

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/5078 **State:** closed **Merged:** No --- # Fix importlib.metadata version detection issue ## Related Issue - Fixes [#5040](https://github.com/langchain-ai/langgraph/issues/5040) - Issue with `importlib.metadata` version detection ## Changes - Modified version detection in `libs/cli/generate_schema.py` to use direct module version access - Updated `libs/checkpoint/langgraph/store/base/embed.py` to implement a more robust version detection system: - Primary method: Direct access to module's `__version__` attribute - Fallback method: `importlib.metadata` version detection - Improved error messages with version information ## Implementation Details The changes implement a two-step version detection process: 1. First attempts to get version directly from the module's `__version__` attribute 2. Falls back to `importlib.metadata` if direct access fails 3. Provides clear error messages about version detection failures ## Testing - Verified that schema generation works correctly with the new version detection logic - Confirmed that all tests pass with the new implementation - Tested both successful and failure scenarios for version detection ## Notes - This change makes version detection more resilient while maintaining backward compatibility - The implementation is compatible with uv's versioning approach - No breaking changes to existing functionality ## Concerns None - The changes are backward compatible and maintain existing functionality while improving reliability. ## Additional Context This fix addresses the issue where `importlib.metadata` version detection could fail in certain environments. The new implementation provides a more robust solution that works across different Python environments and package management systems.
yindo added the pull-request label 2026-02-20 17:49:51 -05:00
yindo closed this issue 2026-02-20 17:49:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#4219