Skip to content

Commit

Permalink
Use pkg_resources instead of pip internal methods (Azure#5252)
Browse files Browse the repository at this point in the history
Modify version and history

Explicitly call list to make pylint happy
  • Loading branch information
derekbekoe authored Jan 9, 2018
1 parent 65f4b2c commit 655af11
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
8 changes: 6 additions & 2 deletions src/azure-cli-core/azure/cli/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ def truncate_text(str_to_shorten, width=70, placeholder=' [...]'):
return str_to_shorten[:s_len] + (str_to_shorten[s_len:] and placeholder)


def get_installed_cli_distributions():
from pkg_resources import working_set
return [d for d in list(working_set) if d.key == CLI_PACKAGE_NAME or d.key.startswith(COMPONENT_PREFIX)]


def get_az_version_string():
import platform
from pip import get_installed_distributions
from azure.cli.core.extension import get_extensions, EXTENSIONS_DIR

output = six.StringIO()
installed_dists = get_installed_distributions(local_only=True)
installed_dists = get_installed_cli_distributions()

cli_info = None
for dist in installed_dists:
Expand Down
4 changes: 4 additions & 0 deletions src/command_modules/azure-cli-feedback/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

2.0.8
+++++
* Minor fixes.

2.0.7
++++++
* Update for CLI core changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from knack.util import CLIError

from azure.cli.core import __version__ as core_version
from azure.cli.core.util import COMPONENT_PREFIX
from azure.cli.core.util import COMPONENT_PREFIX, get_installed_cli_distributions

logger = get_logger(__name__)

Expand Down Expand Up @@ -47,8 +47,7 @@ def _prompt_net_promoter_score():


def _get_version_info():
from pip import get_installed_distributions
installed_dists = get_installed_distributions(local_only=True)
installed_dists = get_installed_cli_distributions()

component_version_info = sorted([{'name': dist.key.replace(COMPONENT_PREFIX, ''),
'version': dist.version}
Expand Down
2 changes: 1 addition & 1 deletion src/command_modules/azure-cli-feedback/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
cmdclass = {}


VERSION = "2.0.7"
VERSION = "2.0.8"
CLASSIFIERS = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
Expand Down
7 changes: 2 additions & 5 deletions tools/automation/verify/verify_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import os.path
import subprocess
import pip
import imp
import glob
import zipfile
import logging
import unittest
from pkg_resources import working_set

import automation.utilities.path as automation_path
from automation.utilities.const import COMMAND_MODULE_PREFIX
Expand Down Expand Up @@ -43,10 +43,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)])

pip.utils.pkg_resources = imp.reload(pip.utils.pkg_resources)
installed_command_modules = [dist.key for dist in
pip.get_installed_distributions(local_only=True)
if dist.key.startswith(COMMAND_MODULE_PREFIX)]
installed_command_modules = [dist.key for dist in list(working_set) if dist.key.startswith(COMMAND_MODULE_PREFIX)]

logger.info('Installed command modules %s', installed_command_modules)

Expand Down

0 comments on commit 655af11

Please sign in to comment.