Skip to content

Conversation

hikeya
Copy link
Contributor

@hikeya hikeya commented Aug 6, 2025

Description

The pkg_resources package used by mqtt_connection_builder and others is scheduled to be removed as early as 2025-11-30.

Details

#626

Test Results

$ python -m unittest test.test_importlib_metadata -v
test_general_exception_handling_mqtt5_client_builder (test.test_importlib_metadata.TestImportlibMetadata.test_general_exception_handling_mqtt5_client_builder)
Test that general exceptions are handled correctly in mqtt5_client_builder ... ok
test_general_exception_handling_mqtt_connection_builder (test.test_importlib_metadata.TestImportlibMetadata.test_general_exception_handling_mqtt_connection_builder)
Test that general exceptions are handled correctly in mqtt_connection_builder ... ok
test_importlib_metadata_available (test.test_importlib_metadata.TestImportlibMetadata.test_importlib_metadata_available)
Test that importlib.metadata is available and working ... ok
test_importlib_metadata_import (test.test_importlib_metadata.TestImportlibMetadata.test_importlib_metadata_import)
Test that importlib.metadata is properly imported in the modified files ... ok
test_metrics_string_generation_mqtt5_client_builder (test.test_importlib_metadata.TestImportlibMetadata.test_metrics_string_generation_mqtt5_client_builder)
Test that mqtt5_client_builder uses importlib.metadata for version detection ... ok
test_metrics_string_generation_mqtt_connection_builder (test.test_importlib_metadata.TestImportlibMetadata.test_metrics_string_generation_mqtt_connection_builder)
Test that mqtt_connection_builder uses importlib.metadata for version detection ... ok
test_no_pkg_resources_import (test.test_importlib_metadata.TestImportlibMetadata.test_no_pkg_resources_import)
Test that pkg_resources is not imported in the modified files ... ok
test_package_not_found_handling_mqtt5_client_builder (test.test_importlib_metadata.TestImportlibMetadata.test_package_not_found_handling_mqtt5_client_builder)
Test that PackageNotFoundError is handled correctly in mqtt5_client_builder ... ok
test_package_not_found_handling_mqtt_connection_builder (test.test_importlib_metadata.TestImportlibMetadata.test_package_not_found_handling_mqtt_connection_builder)
Test that PackageNotFoundError is handled correctly in mqtt_connection_builder ... ok

----------------------------------------------------------------------
Ran 9 tests in 0.082s

OK

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Copilot Copilot AI review requested due to automatic review settings August 6, 2025 14:41
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates from the deprecated pkg_resources package to the standard library importlib.metadata for version detection in MQTT client builders. The change addresses the scheduled removal of pkg_resources as early as 2025-11-30.

  • Replaces pkg_resources.get_distribution() calls with importlib.metadata.version()
  • Updates exception handling from DistributionNotFound to PackageNotFoundError
  • Adds comprehensive test suite to verify the migration works correctly

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
awsiot/mqtt_connection_builder.py Migrates version detection from pkg_resources to importlib.metadata
awsiot/mqtt5_client_builder.py Migrates version detection from pkg_resources to importlib.metadata
test/test_importlib_metadata.py Adds comprehensive test coverage for the importlib.metadata migration

@hikeya hikeya changed the title Fix pkg_resources_deprecated Fix pkg_resources deprecated Aug 6, 2025
@xiazhvera
Copy link
Contributor

Thanks for the contribution! We brought in the PR and made a little adjustment here: #638.

@xiazhvera xiazhvera closed this Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants