Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/release/homebrew/docker/formula_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
36 changes: 6 additions & 30 deletions scripts/release/homebrew/docker/formula_template.txt
Original file line number Diff line number Diff line change
@@ -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 }}"
Expand All @@ -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 = [
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion scripts/release/homebrew/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/azure-cli-core/azure/cli/core/extension/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import traceback
import json
import re

from knack.config import CLIConfig
from knack.log import get_logger
Expand All @@ -29,6 +30,12 @@
EXT_METADATA_MAXCLICOREVERSION = 'azext.maxCliCoreVersion'
EXT_METADATA_ISPREVIEW = 'azext.isPreview'

WHEEL_INFO_RE = re.compile(
r"""^(?P<namever>(?P<name>.+?)(-(?P<ver>\d.+?))?)
((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
\.whl|\.dist-info)$""",
re.VERBOSE).match

logger = get_logger(__name__)


Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/azure-cli-core/azure/cli/core/extension/_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 1 addition & 2 deletions src/azure-cli-core/azure/cli/core/extension/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
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

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
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
'requests>=2.20.0',
'six',
'tabulate>=0.7.7',
'wheel==0.30.0',
'wheel',
'azure-mgmt-resource==2.1.0'
]

Expand Down
2 changes: 1 addition & 1 deletion src/command_modules/azure-cli-extension/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
DEPENDENCIES = [
'azure-cli-core',
'pip',
'wheel==0.30.0',
'wheel',
]

with open('README.rst', 'r', encoding='utf-8') as f:
Expand Down