-
Notifications
You must be signed in to change notification settings - Fork 3.4k
{Misc.} Remove pkg_resources
#31616
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
{Misc.} Remove pkg_resources
#31616
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,3 @@ | |
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| import pkg_resources | ||
| pkg_resources.declare_namespace(__name__) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Confirmed with doc team, they only use |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ | |
| import filecmp | ||
| import logging | ||
| import unittest | ||
| from pkg_resources import working_set | ||
| from importlib.metadata import distributions | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Distribution doc: https://docs.python.org/3/library/importlib.metadata.html#distributions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| import automation.utilities.path as automation_path | ||
| from automation.utilities.const import COMMAND_MODULE_PREFIX | ||
|
|
@@ -48,7 +48,7 @@ def test_azure_cli_installation(self): | |
| def test_azure_cli_module_installation(self): | ||
| expected_modules = set([n for n, _ in automation_path.get_command_modules_paths(include_prefix=True)]) | ||
|
|
||
| installed_command_modules = [dist.key for dist in list(working_set) if dist.key.startswith(COMMAND_MODULE_PREFIX)] | ||
| installed_command_modules = [dist.metadata['Name'] for dist in distributions() if dist.metadata['Name'].startswith(COMMAND_MODULE_PREFIX)] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Another way to access the name of the distribution is @property
def name(self):
"""Return the 'Name' metadata for the distribution package."""
return self.metadata['Name'] |
||
|
|
||
| logger.info('Installed command modules %s', installed_command_modules) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why it declares namespace package. This does not look like a namespace package at all.