diff --git a/scripts/release/homebrew/docker/formula_generate.py b/scripts/release/homebrew/docker/formula_generate.py index d6e899af9d5..d524b471752 100644 --- a/scripts/release/homebrew/docker/formula_generate.py +++ b/scripts/release/homebrew/docker/formula_generate.py @@ -61,7 +61,8 @@ def collect_resources() -> str: def resource_filter(name: str) -> bool: - return not name.startswith('azure-cli') and name not in ('futures') + # TODO remove need for any filters and delete this method. + return not name.startswith('azure-cli') and name not in ('futures', 'jeepney', 'entrypoints') def last_bottle_hash(): diff --git a/scripts/release/homebrew/docker/formula_template.txt b/scripts/release/homebrew/docker/formula_template.txt index c48c8fdacdc..e778670b256 100644 --- a/scripts/release/homebrew/docker/formula_template.txt +++ b/scripts/release/homebrew/docker/formula_template.txt @@ -1,4 +1,6 @@ class AzureCli < Formula + include Language::Python::Virtualenv + desc "Microsoft Azure CLI 2.0" homepage "https://docs.microsoft.com/cli/azure/overview" url "{{ upstream_url }}" @@ -14,12 +16,8 @@ class AzureCli < Formula {{ resources }} def install - xy = Language::Python.major_minor_version "python3" - site_packages = libexec/"lib/python#{xy}/site-packages" - ENV.prepend_create_path "PYTHONPATH", site_packages - ENV.prepend "LDFLAGS", "-L#{Formula["openssl"].opt_lib}" - ENV.prepend "CFLAGS", "-I#{Formula["openssl"].opt_include}" - ENV.prepend "CPPFLAGS", "-I#{Formula["openssl"].opt_include}" + venv = virtualenv_create(libexec, "python3") + venv.pip_install resources # Get the CLI components we'll install components = [ @@ -31,38 +29,16 @@ class AzureCli < Formula ] components += Pathname.glob(buildpath/"src/command_modules/azure-cli-*/") - # Install dependencies - # note: Even if in 'resources', don't include 'futures' as not needed for Python3 - # and causes import errors. See https://github.com/agronholm/pythonfutures/issues/41 - deps = resources.map(&:name).to_set - ["futures"] - deps.each do |r| - resource(r).stage do - system "python3", *Language::Python.setup_install_args(libexec) - end - end - # Install CLI components.each do |item| cd item do - system "python3", *Language::Python.setup_install_args(libexec) + venv.pip_install item end end - # This replaces the `import pkg_resources` namespace imports from upstream - # with empty string as the import is slow and not needed in this environment. - File.open(site_packages/"azure/__init__.py", "w") {} - File.open(site_packages/"azure/cli/__init__.py", "w") {} - File.open(site_packages/"azure/cli/command_modules/__init__.py", "w") {} - File.open(site_packages/"azure/mgmt/__init__.py", "w") {} - (bin/"az").write <<~EOS #!/usr/bin/env bash - export PYTHONPATH="#{ENV["PYTHONPATH"]}" - if command -v python#{xy} >/dev/null 2>&1; then - python#{xy} -m azure.cli \"$@\" - else - python3 -m azure.cli \"$@\" - fi + #{libexec}/bin/python -m azure.cli \"$@\" EOS bash_completion.install "az.completion" => "az" diff --git a/scripts/release/homebrew/docker/run.sh b/scripts/release/homebrew/docker/run.sh index 679abbc07db..e6cefec019b 100755 --- a/scripts/release/homebrew/docker/run.sh +++ b/scripts/release/homebrew/docker/run.sh @@ -2,7 +2,7 @@ root=$(cd $(dirname $0); pwd) -pip install wheel==0.30.0 +pip install wheel pip install -U pip pip install -r $root/requirements.txt pip install azure-cli==$CLI_VERSION -f /mnt/pypi diff --git a/src/azure-cli-core/azure/cli/core/extension/__init__.py b/src/azure-cli-core/azure/cli/core/extension/__init__.py index 22d8e549ac9..8fcfa6c1e3c 100644 --- a/src/azure-cli-core/azure/cli/core/extension/__init__.py +++ b/src/azure-cli-core/azure/cli/core/extension/__init__.py @@ -6,6 +6,7 @@ import os import traceback import json +import re from knack.config import CLIConfig from knack.log import get_logger @@ -29,6 +30,12 @@ EXT_METADATA_MAXCLICOREVERSION = 'azext.maxCliCoreVersion' EXT_METADATA_ISPREVIEW = 'azext.isPreview' +WHEEL_INFO_RE = re.compile( + r"""^(?P(?P.+?)(-(?P\d.+?))?) + ((-(?P\d.*?))?-(?P.+?)-(?P.+?)-(?P.+?) + \.whl|\.dist-info)$""", + re.VERBOSE).match + logger = get_logger(__name__) @@ -108,7 +115,6 @@ def get_version(self): return self.metadata.get('version') def get_metadata(self): - from wheel.install import WHEEL_INFO_RE from glob import glob if not extension_exists(self.name): return None diff --git a/src/azure-cli-core/azure/cli/core/extension/_resolve.py b/src/azure-cli-core/azure/cli/core/extension/_resolve.py index 2a101c3b65f..478cf435ddc 100644 --- a/src/azure-cli-core/azure/cli/core/extension/_resolve.py +++ b/src/azure-cli-core/azure/cli/core/extension/_resolve.py @@ -2,12 +2,11 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -from wheel.install import WHEEL_INFO_RE from pkg_resources import parse_version from knack.log import get_logger -from azure.cli.core.extension import ext_compat_with_cli +from azure.cli.core.extension import ext_compat_with_cli, WHEEL_INFO_RE from azure.cli.core.extension._index import get_index_extensions diff --git a/src/azure-cli-core/azure/cli/core/extension/operations.py b/src/azure-cli-core/azure/cli/core/extension/operations.py index 63a55aecc33..5cfed375a47 100644 --- a/src/azure-cli-core/azure/cli/core/extension/operations.py +++ b/src/azure-cli-core/azure/cli/core/extension/operations.py @@ -14,7 +14,6 @@ from six.moves.urllib.parse import urlparse # pylint: disable=import-error import requests -from wheel.install import WHEEL_INFO_RE from pkg_resources import parse_version from knack.log import get_logger @@ -22,7 +21,7 @@ from azure.cli.core.util import CLIError, reload_module from azure.cli.core.extension import (extension_exists, get_extension_path, get_extensions, get_extension_modname, get_extension, ext_compat_with_cli, EXT_METADATA_ISPREVIEW, - WheelExtension, DevExtension, ExtensionNotInstalledException) + WheelExtension, DevExtension, ExtensionNotInstalledException, WHEEL_INFO_RE) from azure.cli.core.telemetry import set_extension_management_detail from ._homebrew_patch import HomebrewPipPatch diff --git a/src/azure-cli-core/setup.py b/src/azure-cli-core/setup.py index fd46eb1240d..002539ae27c 100644 --- a/src/azure-cli-core/setup.py +++ b/src/azure-cli-core/setup.py @@ -71,7 +71,7 @@ 'requests>=2.20.0', 'six', 'tabulate>=0.7.7', - 'wheel==0.30.0', + 'wheel', 'azure-mgmt-resource==2.1.0' ] diff --git a/src/command_modules/azure-cli-extension/setup.py b/src/command_modules/azure-cli-extension/setup.py index 63c63145383..e66bcb87c0b 100644 --- a/src/command_modules/azure-cli-extension/setup.py +++ b/src/command_modules/azure-cli-extension/setup.py @@ -33,7 +33,7 @@ DEPENDENCIES = [ 'azure-cli-core', 'pip', - 'wheel==0.30.0', + 'wheel', ] with open('README.rst', 'r', encoding='utf-8') as f: