diff --git a/.azure-pipelines/templates/azdev_setup.yml b/.azure-pipelines/templates/azdev_setup.yml index b2836c1a8a3..d33ae283d6d 100644 --- a/.azure-pipelines/templates/azdev_setup.yml +++ b/.azure-pipelines/templates/azdev_setup.yml @@ -14,7 +14,7 @@ steps: chmod +x env/bin/activate . env/bin/activate - pip install -q azdev==0.1.24 + pip install -q azdev==0.1.25 azdev --version if [ -z "$CLI_EXT_REPO_PATH" ]; then diff --git a/.snapcraft.yaml b/.snapcraft.yaml index a48d019ec71..29390985351 100644 --- a/.snapcraft.yaml +++ b/.snapcraft.yaml @@ -28,7 +28,7 @@ parts: - libssl1.0.0 requirements: requirements.txt install: | - python_packages="src/azure-cli-core src/azure-cli-nspkg src/azure-cli-command_modules-nspkg src/command_modules/azure-cli*" + python_packages="src/azure-cli-core src/command_modules/azure-cli*" export PYTHONUSERBASE=$SNAPCRAFT_PART_INSTALL export PYTHONHOME=$SNAPCRAFT_PART_INSTALL/usr echo $SNAPCRAFT_PART_INSTALL/usr/bin/python3 diff --git a/Dockerfile b/Dockerfile index 60dc84bb84a..ecc5a489e39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,7 +50,6 @@ COPY . /azure-cli # 1. Build packages and store in tmp dir # 2. Install the cli and the other command modules that weren't included -# 3. Temporary fix - install azure-nspkg to remove import of pkg_resources in azure/__init__.py (to improve performance) RUN ./scripts/install_full.sh \ && cat /azure-cli/az.completion > ~/.bashrc \ && runDeps="$( \ diff --git a/Dockerfile.nanoserver b/Dockerfile.nanoserver index f6e9bb7597d..442ac8ed942 100644 --- a/Dockerfile.nanoserver +++ b/Dockerfile.nanoserver @@ -78,7 +78,6 @@ foreach($m in $modules) \ { \ & pip install --no-cache-dir $m; \ }\ -& pip install --no-cache-dir --force-reinstall --upgrade azure-nspkg azure-mgmt-nspkg; \ Pop-Location; \ Write-Host 'Done'; diff --git a/Dockerfile.spot b/Dockerfile.spot index fb2b3e3738b..91937df010c 100644 --- a/Dockerfile.spot +++ b/Dockerfile.spot @@ -33,15 +33,13 @@ COPY . /azure-cli # jmespath-terminal - we include jpterm as a useful tool # 1. Build packages and store in tmp dir # 2. Install the cli and the other command modules that weren't included -# 3. Temporary fix - install azure-nspkg to remove import of pkg_resources in azure/__init__.py (to improve performance) RUN /bin/bash -c 'TMP_PKG_DIR=$(mktemp -d); \ - for d in src/azure-cli src/azure-cli-core src/azure-cli-nspkg src/azure-cli-command_modules-nspkg src/command_modules/azure-cli-*/; \ + for d in src/azure-cli src/azure-cli-core src/command_modules/azure-cli-*/; \ do cd $d; echo $d; python setup.py bdist_wheel -d $TMP_PKG_DIR; cd -; \ done; \ [ -d privates ] && cp privates/*.whl $TMP_PKG_DIR; \ all_modules=`find $TMP_PKG_DIR -name "*.whl"`; \ - pip install --no-cache-dir $all_modules; \ - pip install --no-cache-dir --force-reinstall --upgrade azure-nspkg azure-mgmt-nspkg;' \ + pip install --no-cache-dir $all_modules;' \ && cat /azure-cli/az.completion > ~/.bashrc WORKDIR / diff --git a/azure-cli.pyproj b/azure-cli.pyproj index d32a0c24106..cf4117aca47 100644 --- a/azure-cli.pyproj +++ b/azure-cli.pyproj @@ -23,8 +23,6 @@ 10.0 - - @@ -78,8 +76,6 @@ - - @@ -785,10 +781,6 @@ - - - - @@ -797,9 +789,6 @@ - - - @@ -1130,13 +1119,8 @@ - - - - - diff --git a/azure-cli2017.pyproj b/azure-cli2017.pyproj index 3f8678a853f..5202fd4ad50 100644 --- a/azure-cli2017.pyproj +++ b/azure-cli2017.pyproj @@ -23,8 +23,6 @@ 10.0 - - @@ -90,8 +88,6 @@ - - @@ -980,10 +976,6 @@ - - - - @@ -997,9 +989,6 @@ - - - @@ -1217,10 +1206,6 @@ - - - - @@ -1234,8 +1219,6 @@ - - diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5ad693a2d66..21b9b248100 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -572,6 +572,33 @@ jobs: displayName: 'Bash Script' +- job: TestHomebrewPackage + displayName: Test Homebrew Package + timeoutInMinutes: 120 + dependsOn: BuildHomebrewFormula + condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'Manual')) + pool: + vmImage: 'macOS-10.14' + steps: + - task: DownloadPipelineArtifact@1 + displayName: 'Download Metadata' + inputs: + TargetPath: '$(Build.ArtifactStagingDirectory)/metadata' + artifactName: metadata + + + - task: DownloadPipelineArtifact@1 + displayName: 'Download Build Artifacts' + inputs: + TargetPath: '$(Build.ArtifactStagingDirectory)/homebrew' + artifactName: homebrew + + + - bash: ./scripts/release/homebrew/test_homebrew_package.sh + + + displayName: 'Test Homebrew Package' + - job: BuildYumPackage displayName: Build Yum Package diff --git a/build_scripts/windows/scripts/build.cmd b/build_scripts/windows/scripts/build.cmd index 813f7965192..5479ca84c24 100644 --- a/build_scripts/windows/scripts/build.cmd +++ b/build_scripts/windows/scripts/build.cmd @@ -88,7 +88,7 @@ robocopy %PYTHON_DIR% %BUILDING_DIR% /s /NFL /NDL set CLI_SRC=%REPO_ROOT%\src %BUILDING_DIR%\python.exe -m pip install --no-warn-script-location --force-reinstall pycparser==2.18 -for %%a in (%CLI_SRC%\azure-cli %CLI_SRC%\azure-cli-core %CLI_SRC%\azure-cli-nspkg %CLI_SRC%\azure-cli-telemetry) do ( +for %%a in (%CLI_SRC%\azure-cli %CLI_SRC%\azure-cli-core %CLI_SRC%\azure-cli-telemetry) do ( pushd %%a %BUILDING_DIR%\python.exe -m pip install --no-warn-script-location --no-cache-dir --no-deps . popd @@ -97,8 +97,6 @@ for %%a in (%CLI_SRC%\azure-cli %CLI_SRC%\azure-cli-core %CLI_SRC%\azure-cli-nsp if %errorlevel% neq 0 goto ERROR -%BUILDING_DIR%\python.exe -m pip install --no-warn-script-location --force-reinstall --upgrade azure-nspkg azure-mgmt-nspkg - pushd %BUILDING_DIR% %BUILDING_DIR%\python.exe %~dp0\patch_models_v2.py popd diff --git a/doc/authoring_command_modules/README.md b/doc/authoring_command_modules/README.md index af68b179341..5c9c4f804f0 100644 --- a/doc/authoring_command_modules/README.md +++ b/doc/authoring_command_modules/README.md @@ -55,10 +55,6 @@ Also, you can run `az` and if your command module contributes any commands, they If your commands aren't showing with `az`, use `az --debug` to help debug. There could have been an exception thrown whilst attempting to load your module. -**Note for locally installed Azure SDKs:** -If you're receiving Azure import errors, run `pip install -I azure-nspkg==1.0.0` in your virtual environment -after installing your SDK locally. - Authoring command modules ------ diff --git a/scripts/ci/version.sh b/scripts/ci/version.sh index 8d1c3a619e6..9b3d2acf4b9 100755 --- a/scripts/ci/version.sh +++ b/scripts/ci/version.sh @@ -20,6 +20,14 @@ echo "Replace with version: $version" platform=`uname` +for each in $(find src -name __main__.py); do + if [ "$platform" == "Darwin" ]; then + sed -i "" "s/^__version__ = [\"']\(.*\)[\"']/__version__ = \"\1.dev$version\"/" $each + else + sed -i "s/^__version__ = [\"']\(.*\)[\"']/__version__ = \"\1.dev$version\"/" $each + fi +done + for each in $(find src -name __init__.py); do if [ "$platform" == "Darwin" ]; then sed -i "" "s/^__version__ = [\"']\(.*\)[\"']/__version__ = \"\1.dev$version\"/" $each diff --git a/scripts/curl_install_pypi/install.py b/scripts/curl_install_pypi/install.py index 975091f8253..29b4b4c5c4b 100644 --- a/scripts/curl_install_pypi/install.py +++ b/scripts/curl_install_pypi/install.py @@ -149,10 +149,6 @@ def install_cli(install_dir, tmp_dir): path_to_pip = os.path.join(install_dir, 'bin', 'pip') cmd = [path_to_pip, 'install', '--cache-dir', tmp_dir, 'azure-cli', '--upgrade'] exec_command(cmd) - # Temporary fix to make sure that we have empty __init__.py files for the azure site-packages folder. - # (including the pkg_resources/declare namespace significantly impacts startup perf for the CLI) - fixupcmd = [path_to_pip, 'install', '--cache-dir', tmp_dir, '--upgrade', '--force-reinstall', 'azure-nspkg', 'azure-mgmt-nspkg'] - exec_command(fixupcmd) def create_executable(exec_dir, install_dir): diff --git a/scripts/dev_setup.py b/scripts/dev_setup.py index 5557f7d09d1..03032645ed3 100755 --- a/scripts/dev_setup.py +++ b/scripts/dev_setup.py @@ -66,7 +66,6 @@ def pip_command(command): pip_command('install -e ./tools') # command modules have dependency on azure-cli-core so install this first -pip_command('install -e src/azure-cli-nspkg') pip_command('install -e src/azure-cli-telemetry') pip_command('install -e src/azure-cli-core') py_command('-m automation.setup.install_modules') @@ -75,11 +74,6 @@ def pip_command(command): pip_command('install -e src/azure-cli') pip_command('install -e src/azure-cli-testsdk') -# Ensure that the site package's azure/__init__.py has the old style namespace -# package declaration by installing the old namespace package -pip_command('install --force-reinstall azure-nspkg==1.0.0') -pip_command('install --force-reinstall azure-mgmt-nspkg==1.0.0') - print_support_message() print('Finished dev setup.') diff --git a/scripts/release/debian/Dockerfile b/scripts/release/debian/Dockerfile index a45c419a20b..bc408223447 100644 --- a/scripts/release/debian/Dockerfile +++ b/scripts/release/debian/Dockerfile @@ -29,7 +29,6 @@ RUN mkdir -p ./bin/pypi && \ BUILD_STAGINGDIRECTORY=/azure-cli/bin/pypi ./scripts/release/pypi/build.sh && \ if [ -d ./privates ]; then find ./privates -name '*.whl' | xargs pip install; fi && \ find ./bin/pypi -name '*.whl' | xargs pip install && \ - pip install --force-reinstall --upgrade azure-nspkg azure-mgmt-nspkg && \ pip install --force-reinstall urllib3==1.24.2 ARG cli_version=0.0.0-dev diff --git a/scripts/release/debian/pipeline.sh b/scripts/release/debian/pipeline.sh index 83ba0c81eae..bd9d7bdeebc 100755 --- a/scripts/release/debian/pipeline.sh +++ b/scripts/release/debian/pipeline.sh @@ -8,7 +8,7 @@ set -exv : ${DISTRO:?"DISTRO is not set"} : ${DISTRO_BASE_IMAGE:?"DISTRO_BASE_IMAGE is not set"} -CLI_VERSION=`cat src/azure-cli/azure/cli/__init__.py | grep __version__ | sed s/' '//g | sed s/'__version__='// | sed s/\"//g` +CLI_VERSION=`cat src/azure-cli/azure/cli/__main__.py | grep __version__ | sed s/' '//g | sed s/'__version__='// | sed s/\"//g` docker run --rm \ -v "$BUILD_SOURCESDIRECTORY":/mnt/repo \ diff --git a/scripts/release/docker/pipeline.sh b/scripts/release/docker/pipeline.sh index 2f5a5cb4630..01b727a80ef 100755 --- a/scripts/release/docker/pipeline.sh +++ b/scripts/release/docker/pipeline.sh @@ -1,5 +1,5 @@ IMAGE_NAME=clibuild$BUILD_BUILDNUMBER -CLI_VERSION=`cat src/azure-cli/azure/cli/__init__.py | grep __version__ | sed s/' '//g | sed s/'__version__='// | sed s/\"//g` +CLI_VERSION=`cat src/azure-cli/azure/cli/__main__.py | grep __version__ | sed s/' '//g | sed s/'__version__='// | sed s/\"//g` docker build --no-cache \ --build-arg BUILD_DATE="`date -u +"%Y-%m-%dT%H:%M:%SZ"`" \ diff --git a/scripts/release/get_version.sh b/scripts/release/get_version.sh index 6b9d65b11b0..a3093b6927d 100755 --- a/scripts/release/get_version.sh +++ b/scripts/release/get_version.sh @@ -1,7 +1,7 @@ -# Extract the version of the CLI from azure-cli package's __init__.py file. +# Extract the version of the CLI from azure-cli package's __main__.py file. : "${BUILD_STAGINGDIRECTORY:?BUILD_STAGINGDIRECTORY environment variable not set}" -ver=`cat src/azure-cli/azure/cli/__init__.py | grep __version__ | sed s/' '//g | sed s/'__version__='// | sed s/\"//g` +ver=`cat src/azure-cli/azure/cli/__main__.py | grep __version__ | sed s/' '//g | sed s/'__version__='// | sed s/\"//g` echo $ver > $BUILD_STAGINGDIRECTORY/version echo $ver > $BUILD_STAGINGDIRECTORY/azure-cli-${ver}.txt \ No newline at end of file diff --git a/scripts/release/homebrew/docker/formula_template.txt b/scripts/release/homebrew/docker/formula_template.txt index b8f254e211a..89d47b483cb 100644 --- a/scripts/release/homebrew/docker/formula_template.txt +++ b/scripts/release/homebrew/docker/formula_template.txt @@ -6,6 +6,7 @@ class AzureCli < Formula url "{{ upstream_url }}" version "{{ cli_version }}" sha256 "{{ upstream_sha }}" + license "MIT" head "https://github.com/Azure/azure-cli.git" {{ bottle_hash }} @@ -13,6 +14,12 @@ class AzureCli < Formula depends_on "openssl@1.1" depends_on "python@3.8" + uses_from_macos "libffi" + + on_linux do + depends_on "pkg-config" => :build + end + {{ resources }} def install @@ -28,8 +35,6 @@ class AzureCli < Formula buildpath/"src/azure-cli", buildpath/"src/azure-cli-telemetry", buildpath/"src/azure-cli-core", - buildpath/"src/azure-cli-nspkg", - buildpath/"src/azure-cli-command_modules-nspkg", ] # Install CLI diff --git a/scripts/release/homebrew/docker/run.sh b/scripts/release/homebrew/docker/run.sh index b1375310371..2242efb8be9 100755 --- a/scripts/release/homebrew/docker/run.sh +++ b/scripts/release/homebrew/docker/run.sh @@ -10,4 +10,4 @@ pip install -r /mnt/src/azure-cli/requirements.py3.Darwin.txt pip list -python $root/formula_generate.py +python $root/formula_generate.py -b use_template diff --git a/scripts/release/homebrew/test_homebrew_package.py b/scripts/release/homebrew/test_homebrew_package.py new file mode 100644 index 00000000000..447520c2da4 --- /dev/null +++ b/scripts/release/homebrew/test_homebrew_package.py @@ -0,0 +1,34 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import os +import sys +import subprocess + +if len(sys.argv) < 2: + print('AZ_BASE or PYTHON_VERSION are not specified') + sys.exit(-1) + +az_base = sys.argv[1] +python_version = sys.argv[2] + +root_dir = '{}/lib/{}/site-packages/azure/cli/command_modules'.format(az_base, python_version) +mod_list = [mod for mod in sorted(os.listdir(root_dir)) if os.path.isdir(os.path.join(root_dir, mod)) and mod != '__pycache__'] + +pytest_base_cmd = 'PYTHONPATH={}/lib/{}/site-packages python -m pytest -x -v --boxed -p no:warnings --log-level=WARN'.format(az_base, python_version) +pytest_parallel_cmd = '{} -n auto'.format(pytest_base_cmd) + +for mod_name in mod_list: + if mod_name in ['botservice', 'network', 'configure']: + exit_code = subprocess.call(['{} --junit-xml ./azure_cli_test_result/{}.xml --pyargs azure.cli.command_modules.{}'.format(pytest_base_cmd, mod_name, mod_name)], shell=True) + else: + exit_code = subprocess.call(['{} --junit-xml ./azure_cli_test_result/{}.xml --pyargs azure.cli.command_modules.{}'.format(pytest_parallel_cmd, mod_name, mod_name)], shell=True) + if exit_code == 5: + print('No tests found for {}'.format(mod_name)) + elif exit_code != 0: + sys.exit(exit_code) + +exit_code = subprocess.call(['{} --junit-xml ./azure_cli_test_result/azure-cli-core.xml --pyargs azure.cli.core'.format(pytest_base_cmd)], shell=True) +sys.exit(exit_code) diff --git a/scripts/release/homebrew/test_homebrew_package.sh b/scripts/release/homebrew/test_homebrew_package.sh new file mode 100755 index 00000000000..f53bd82aa21 --- /dev/null +++ b/scripts/release/homebrew/test_homebrew_package.sh @@ -0,0 +1,29 @@ +#/bin/bash + +set -ev + +CLI_VERSION=`cat $SYSTEM_ARTIFACTSDIRECTORY/metadata/version` + +echo == Remove pre-installed azure-cli == +brew uninstall azure-cli + +echo == Install azure-cli.rb formula == +brew install --build-from-source $SYSTEM_ARTIFACTSDIRECTORY/homebrew/azure-cli.rb + +AZ_BASE=/usr/local/Cellar/azure-cli/$CLI_VERSION/libexec +export PATH=$AZ_BASE/bin:$PATH +export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES +echo $PATH +pip install wheel +./scripts/ci/build.sh +pip install pytest --prefix $AZ_BASE +pip install pytest-xdist --prefix $AZ_BASE + +find ./artifacts/build -name "azure_cli_testsdk*" | xargs pip install --prefix $AZ_BASE --upgrade --ignore-installed +find ./artifacts/build -name "azure_cli_fulltest*" | xargs pip install --prefix $AZ_BASE --upgrade --ignore-installed --no-deps + +# workaround for this bug (https://github.com/microsoft/azure-devops-python-api/issues/354) +mkdir -p ~/.vsts/python-sdk/cache + +PYTHON_VERSION=`ls $AZ_BASE/lib/ | head -n 1` +python ./scripts/release/homebrew/test_homebrew_package.py $AZ_BASE $PYTHON_VERSION \ No newline at end of file diff --git a/scripts/release/rpm/pipeline.sh b/scripts/release/rpm/pipeline.sh index 36d44b06d5c..df6958a1c8d 100755 --- a/scripts/release/rpm/pipeline.sh +++ b/scripts/release/rpm/pipeline.sh @@ -6,7 +6,7 @@ set -exv : "${BUILD_STAGINGDIRECTORY:?BUILD_STAGINGDIRECTORY environment variable not set.}" -CLI_VERSION=`cat src/azure-cli/azure/cli/__init__.py | grep __version__ | sed s/' '//g | sed s/'__version__='// | sed s/\"//g` +CLI_VERSION=`cat src/azure-cli/azure/cli/__main__.py | grep __version__ | sed s/' '//g | sed s/'__version__='// | sed s/\"//g` # Create a container image that includes the source code and a built RPM using this file. docker build \ diff --git a/src/azure-cli-command_modules-nspkg/HISTORY.rst b/src/azure-cli-command_modules-nspkg/HISTORY.rst deleted file mode 100644 index e7931547390..00000000000 --- a/src/azure-cli-command_modules-nspkg/HISTORY.rst +++ /dev/null @@ -1,19 +0,0 @@ -.. :changelog: - -Release History -=============== -2.0.3 -+++++ -* Indicate Python 3.7 support. - -2.0.2 -++++++ -* Minor fixes. - -2.0.1 -+++++ -* minor fixes - -2.0.0 (2017-04-28) -++++++++++++++++++ -* Initial release diff --git a/src/azure-cli-command_modules-nspkg/MANIFEST.in b/src/azure-cli-command_modules-nspkg/MANIFEST.in deleted file mode 100644 index bb37a2723da..00000000000 --- a/src/azure-cli-command_modules-nspkg/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -include *.rst diff --git a/src/azure-cli-command_modules-nspkg/README.rst b/src/azure-cli-command_modules-nspkg/README.rst deleted file mode 100644 index 1ea0535b66b..00000000000 --- a/src/azure-cli-command_modules-nspkg/README.rst +++ /dev/null @@ -1,8 +0,0 @@ -Microsoft Azure CLI Command modules Namespace Package -===================================================== - -This is the Microsoft Azure CLI command module namespace package. - -This package is not intended to be installed directly by the end user. - -It provides the necessary files for other packages to extend the azure cli command module namespaces. diff --git a/src/azure-cli-command_modules-nspkg/azure/cli/command_modules/__init__.py b/src/azure-cli-command_modules-nspkg/azure/cli/command_modules/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/azure-cli-command_modules-nspkg/setup.cfg b/src/azure-cli-command_modules-nspkg/setup.cfg deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/azure-cli-command_modules-nspkg/setup.py b/src/azure-cli-command_modules-nspkg/setup.py deleted file mode 100644 index 2cfe3b6241f..00000000000 --- a/src/azure-cli-command_modules-nspkg/setup.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python - -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -from codecs import open -from setuptools import setup - -VERSION = "2.0.3" - -CLASSIFIERS = [ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Intended Audience :: System Administrators', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'License :: OSI Approved :: MIT License', -] - -with open('README.rst', 'r', encoding='utf-8') as f: - README = f.read() -with open('HISTORY.rst', 'r', encoding='utf-8') as f: - HISTORY = f.read() - -setup( - name='azure-cli-command-modules-nspkg', - version=VERSION, - description='Microsoft Azure CLI Command Modules Namespace Package', - long_description=README + '\n\n' + HISTORY, - license='MIT', - author='Microsoft Corporation', - author_email='azpycli@microsoft.com', - url='https://github.com/Azure/azure-cli', - zip_safe=False, - classifiers=CLASSIFIERS, - install_requires=[ - 'azure-cli-nspkg>=3.0.0' - ], - packages=[ - 'azure', - 'azure.cli', - 'azure.cli.command_modules' - ], -) diff --git a/src/azure-cli-core/MANIFEST.in b/src/azure-cli-core/MANIFEST.in index 9ecaeb15de5..69ea6552b6e 100644 --- a/src/azure-cli-core/MANIFEST.in +++ b/src/azure-cli-core/MANIFEST.in @@ -1,2 +1,3 @@ include *.rst -include azure_bdist_wheel.py \ No newline at end of file +include azure/__init__.py +include azure/cli/__init__.py \ No newline at end of file diff --git a/src/azure-cli-core/azure/__init__.py b/src/azure-cli-core/azure/__init__.py index 73baee1e640..2ae78104e94 100644 --- a/src/azure-cli-core/azure/__init__.py +++ b/src/azure-cli-core/azure/__init__.py @@ -2,5 +2,4 @@ # 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__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/src/azure-cli-core/azure/cli/__init__.py b/src/azure-cli-core/azure/cli/__init__.py index 73baee1e640..2ae78104e94 100644 --- a/src/azure-cli-core/azure/cli/__init__.py +++ b/src/azure-cli-core/azure/cli/__init__.py @@ -2,5 +2,4 @@ # 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__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/src/azure-cli-core/azure_bdist_wheel.py b/src/azure-cli-core/azure_bdist_wheel.py deleted file mode 100644 index 8a81d1b6177..00000000000 --- a/src/azure-cli-core/azure_bdist_wheel.py +++ /dev/null @@ -1,54 +0,0 @@ -#------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -#-------------------------------------------------------------------------- - -from distutils import log as logger -import os.path - -from wheel.bdist_wheel import bdist_wheel -class azure_bdist_wheel(bdist_wheel): - """The purpose of this class is to build wheel a little differently than the sdist, - without requiring to build the wheel from the sdist (i.e. you can build the wheel - directly from source). - """ - - description = "Create an Azure wheel distribution" - - user_options = bdist_wheel.user_options + \ - [('azure-namespace-package=', None, - "Name of the deepest nspkg used")] - - def initialize_options(self): - bdist_wheel.initialize_options(self) - self.azure_namespace_package = None - - def finalize_options(self): - bdist_wheel.finalize_options(self) - if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"): - raise ValueError("azure_namespace_package must finish by -nspkg") - - def run(self): - if not self.distribution.install_requires: - self.distribution.install_requires = [] - self.distribution.install_requires.append( - "{}>=2.0.0".format(self.azure_namespace_package)) - bdist_wheel.run(self) - - def write_record(self, bdist_dir, distinfo_dir): - if self.azure_namespace_package: - # Split and remove last part, assuming it's "nspkg" - subparts = self.azure_namespace_package.split('-')[0:-1] - folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))] - for azure_sub_package in folder_with_init: - init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py') - if os.path.isfile(init_file): - logger.info("manually remove {} while building the wheel".format(init_file)) - os.remove(init_file) - else: - raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file)) - bdist_wheel.write_record(self, bdist_dir, distinfo_dir) -cmdclass = { - 'bdist_wheel': azure_bdist_wheel, -} diff --git a/src/azure-cli-core/setup.cfg b/src/azure-cli-core/setup.cfg index 06af3bd4360..e69de29bb2d 100644 --- a/src/azure-cli-core/setup.cfg +++ b/src/azure-cli-core/setup.cfg @@ -1,2 +0,0 @@ -[bdist_wheel] -azure-namespace-package=azure-cli-nspkg diff --git a/src/azure-cli-core/setup.py b/src/azure-cli-core/setup.py index 71d809246a2..9ef61eb2584 100644 --- a/src/azure-cli-core/setup.py +++ b/src/azure-cli-core/setup.py @@ -9,15 +9,8 @@ from codecs import open from setuptools import setup -try: - from azure_bdist_wheel import cmdclass -except ImportError: - from distutils import log as logger - - logger.warn("Wheel is not available, disabling bdist_wheel hook") - cmdclass = {} - VERSION = "2.10.1" + # If we have source, validate that our version numbers match # This should prevent uploading releases with mismatched versions. try: @@ -92,8 +85,6 @@ zip_safe=False, classifiers=CLASSIFIERS, packages=[ - 'azure', - 'azure.cli', 'azure.cli.core', 'azure.cli.core.commands', 'azure.cli.core.extension', @@ -107,6 +98,5 @@ "test": TESTS_REQUIRE, }, tests_require=TESTS_REQUIRE, - package_data={'azure.cli.core': ['auth_landing_pages/*.html']}, - cmdclass=cmdclass + package_data={'azure.cli.core': ['auth_landing_pages/*.html']} ) diff --git a/src/azure-cli-nspkg/HISTORY.rst b/src/azure-cli-nspkg/HISTORY.rst deleted file mode 100644 index 43af6f5726b..00000000000 --- a/src/azure-cli-nspkg/HISTORY.rst +++ /dev/null @@ -1,44 +0,0 @@ -.. :changelog: - -Release History -=============== -3.0.4 -+++++ -* Indicate Python 3.7 support. - -3.0.3 -++++++ -* Minor fixes. - -3.0.2 -+++++ -* minor fixes - -3.0.1 -+++++ -* minor fixes - -3.0.0 (2016-04-28) -++++++++++++++++++ - -* New nspkg structure. - -2.0.0 (2016-02-27) -++++++++++++++++++ - -* GA release. - -0.1.2 (2016-01-30) -++++++++++++++++++ - -* Support Python 3.6. - -0.1.1 (2016-01-17) -++++++++++++++++++ - -* Stable release (no code changes since previous version). - -0.1.0b11 (2016-12-12) -+++++++++++++++++++++ - -* Preview release. diff --git a/src/azure-cli-nspkg/MANIFEST.in b/src/azure-cli-nspkg/MANIFEST.in deleted file mode 100644 index bb37a2723da..00000000000 --- a/src/azure-cli-nspkg/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -include *.rst diff --git a/src/azure-cli-nspkg/README.rst b/src/azure-cli-nspkg/README.rst deleted file mode 100644 index 7d2fd556eb1..00000000000 --- a/src/azure-cli-nspkg/README.rst +++ /dev/null @@ -1,8 +0,0 @@ -Microsoft Azure CLI Namespace Package -===================================== - -This is the Microsoft Azure CLI namespace package. - -This package is not intended to be installed directly by the end user. - -It provides the necessary files for other packages to extend the azure cli namespaces. diff --git a/src/azure-cli-nspkg/azure/cli/__init__.py b/src/azure-cli-nspkg/azure/cli/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/azure-cli-nspkg/setup.cfg b/src/azure-cli-nspkg/setup.cfg deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/azure-cli-nspkg/setup.py b/src/azure-cli-nspkg/setup.py deleted file mode 100644 index fb01c0b8d9f..00000000000 --- a/src/azure-cli-nspkg/setup.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python - -# -------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# -------------------------------------------------------------------------------------------- - -from codecs import open -from setuptools import setup - -VERSION = "3.0.4" - -CLASSIFIERS = [ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Intended Audience :: System Administrators', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'License :: OSI Approved :: MIT License', -] - -with open('README.rst', 'r', encoding='utf-8') as f: - README = f.read() -with open('HISTORY.rst', 'r', encoding='utf-8') as f: - HISTORY = f.read() - -setup( - name='azure-cli-nspkg', - version=VERSION, - description='Microsoft Azure CLI Namespace Package', - long_description=README + '\n\n' + HISTORY, - license='MIT', - author='Microsoft Corporation', - author_email='azpycli@microsoft.com', - url='https://github.com/Azure/azure-cli', - zip_safe=False, - classifiers=CLASSIFIERS, - install_requires=[ - 'azure-nspkg>=2.0.0' - ], - packages=[ - 'azure', - 'azure.cli', - ], -) diff --git a/src/azure-cli-telemetry/HISTORY.rst b/src/azure-cli-telemetry/HISTORY.rst index be11b3b7864..ed953bae2f0 100644 --- a/src/azure-cli-telemetry/HISTORY.rst +++ b/src/azure-cli-telemetry/HISTORY.rst @@ -2,6 +2,10 @@ Release History =============== +1.0.5 ++++++ +* Support PEP420 namespace package + 1.0.4 +++++ * MANIFEST file change to fix wheel install diff --git a/src/azure-cli-telemetry/MANIFEST.in b/src/azure-cli-telemetry/MANIFEST.in index 9ecaeb15de5..69ea6552b6e 100644 --- a/src/azure-cli-telemetry/MANIFEST.in +++ b/src/azure-cli-telemetry/MANIFEST.in @@ -1,2 +1,3 @@ include *.rst -include azure_bdist_wheel.py \ No newline at end of file +include azure/__init__.py +include azure/cli/__init__.py \ No newline at end of file diff --git a/src/azure-cli-telemetry/azure/__init__.py b/src/azure-cli-telemetry/azure/__init__.py index 73baee1e640..2ae78104e94 100644 --- a/src/azure-cli-telemetry/azure/__init__.py +++ b/src/azure-cli-telemetry/azure/__init__.py @@ -2,5 +2,4 @@ # 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__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/src/azure-cli-telemetry/azure/cli/__init__.py b/src/azure-cli-telemetry/azure/cli/__init__.py index bb3f1f13b5e..2ae78104e94 100644 --- a/src/azure-cli-telemetry/azure/cli/__init__.py +++ b/src/azure-cli-telemetry/azure/cli/__init__.py @@ -2,6 +2,4 @@ # 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__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/src/azure-cli-telemetry/azure_bdist_wheel.py b/src/azure-cli-telemetry/azure_bdist_wheel.py deleted file mode 100644 index 8a81d1b6177..00000000000 --- a/src/azure-cli-telemetry/azure_bdist_wheel.py +++ /dev/null @@ -1,54 +0,0 @@ -#------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -#-------------------------------------------------------------------------- - -from distutils import log as logger -import os.path - -from wheel.bdist_wheel import bdist_wheel -class azure_bdist_wheel(bdist_wheel): - """The purpose of this class is to build wheel a little differently than the sdist, - without requiring to build the wheel from the sdist (i.e. you can build the wheel - directly from source). - """ - - description = "Create an Azure wheel distribution" - - user_options = bdist_wheel.user_options + \ - [('azure-namespace-package=', None, - "Name of the deepest nspkg used")] - - def initialize_options(self): - bdist_wheel.initialize_options(self) - self.azure_namespace_package = None - - def finalize_options(self): - bdist_wheel.finalize_options(self) - if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"): - raise ValueError("azure_namespace_package must finish by -nspkg") - - def run(self): - if not self.distribution.install_requires: - self.distribution.install_requires = [] - self.distribution.install_requires.append( - "{}>=2.0.0".format(self.azure_namespace_package)) - bdist_wheel.run(self) - - def write_record(self, bdist_dir, distinfo_dir): - if self.azure_namespace_package: - # Split and remove last part, assuming it's "nspkg" - subparts = self.azure_namespace_package.split('-')[0:-1] - folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))] - for azure_sub_package in folder_with_init: - init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py') - if os.path.isfile(init_file): - logger.info("manually remove {} while building the wheel".format(init_file)) - os.remove(init_file) - else: - raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file)) - bdist_wheel.write_record(self, bdist_dir, distinfo_dir) -cmdclass = { - 'bdist_wheel': azure_bdist_wheel, -} diff --git a/src/azure-cli-telemetry/setup.cfg b/src/azure-cli-telemetry/setup.cfg index 06af3bd4360..8b137891791 100644 --- a/src/azure-cli-telemetry/setup.cfg +++ b/src/azure-cli-telemetry/setup.cfg @@ -1,2 +1 @@ -[bdist_wheel] -azure-namespace-package=azure-cli-nspkg + diff --git a/src/azure-cli-telemetry/setup.py b/src/azure-cli-telemetry/setup.py index de4aded426e..28a90870376 100755 --- a/src/azure-cli-telemetry/setup.py +++ b/src/azure-cli-telemetry/setup.py @@ -8,15 +8,7 @@ from codecs import open from setuptools import setup -try: - from azure_bdist_wheel import cmdclass -except ImportError: - from distutils import log as logger - - logger.warn("Wheel is not available, disabling bdist_wheel hook") - cmdclass = {} - -VERSION = "1.0.4" +VERSION = "1.0.5" CLASSIFIERS = [ 'Development Status :: 5 - Production/Stable', @@ -51,13 +43,10 @@ 'portalocker~=1.2', ], packages=[ - 'azure', - 'azure.cli', 'azure.cli.telemetry', 'azure.cli.telemetry.components' ], test_requires=[ 'mock' - ], - cmdclass=cmdclass + ] ) diff --git a/src/azure-cli-testsdk/MANIFEST.in b/src/azure-cli-testsdk/MANIFEST.in index 9ecaeb15de5..69ea6552b6e 100644 --- a/src/azure-cli-testsdk/MANIFEST.in +++ b/src/azure-cli-testsdk/MANIFEST.in @@ -1,2 +1,3 @@ include *.rst -include azure_bdist_wheel.py \ No newline at end of file +include azure/__init__.py +include azure/cli/__init__.py \ No newline at end of file diff --git a/src/azure-cli-testsdk/azure/__init__.py b/src/azure-cli-testsdk/azure/__init__.py index a9dfa5391b9..2ae78104e94 100644 --- a/src/azure-cli-testsdk/azure/__init__.py +++ b/src/azure-cli-testsdk/azure/__init__.py @@ -2,6 +2,4 @@ # 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__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/src/azure-cli-testsdk/azure/cli/__init__.py b/src/azure-cli-testsdk/azure/cli/__init__.py index a9dfa5391b9..2ae78104e94 100644 --- a/src/azure-cli-testsdk/azure/cli/__init__.py +++ b/src/azure-cli-testsdk/azure/cli/__init__.py @@ -2,6 +2,4 @@ # 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__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/src/azure-cli-testsdk/azure_bdist_wheel.py b/src/azure-cli-testsdk/azure_bdist_wheel.py deleted file mode 100644 index 8a81d1b6177..00000000000 --- a/src/azure-cli-testsdk/azure_bdist_wheel.py +++ /dev/null @@ -1,54 +0,0 @@ -#------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -#-------------------------------------------------------------------------- - -from distutils import log as logger -import os.path - -from wheel.bdist_wheel import bdist_wheel -class azure_bdist_wheel(bdist_wheel): - """The purpose of this class is to build wheel a little differently than the sdist, - without requiring to build the wheel from the sdist (i.e. you can build the wheel - directly from source). - """ - - description = "Create an Azure wheel distribution" - - user_options = bdist_wheel.user_options + \ - [('azure-namespace-package=', None, - "Name of the deepest nspkg used")] - - def initialize_options(self): - bdist_wheel.initialize_options(self) - self.azure_namespace_package = None - - def finalize_options(self): - bdist_wheel.finalize_options(self) - if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"): - raise ValueError("azure_namespace_package must finish by -nspkg") - - def run(self): - if not self.distribution.install_requires: - self.distribution.install_requires = [] - self.distribution.install_requires.append( - "{}>=2.0.0".format(self.azure_namespace_package)) - bdist_wheel.run(self) - - def write_record(self, bdist_dir, distinfo_dir): - if self.azure_namespace_package: - # Split and remove last part, assuming it's "nspkg" - subparts = self.azure_namespace_package.split('-')[0:-1] - folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))] - for azure_sub_package in folder_with_init: - init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py') - if os.path.isfile(init_file): - logger.info("manually remove {} while building the wheel".format(init_file)) - os.remove(init_file) - else: - raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file)) - bdist_wheel.write_record(self, bdist_dir, distinfo_dir) -cmdclass = { - 'bdist_wheel': azure_bdist_wheel, -} diff --git a/src/azure-cli-testsdk/setup.cfg b/src/azure-cli-testsdk/setup.cfg index 06af3bd4360..e69de29bb2d 100644 --- a/src/azure-cli-testsdk/setup.cfg +++ b/src/azure-cli-testsdk/setup.cfg @@ -1,2 +0,0 @@ -[bdist_wheel] -azure-namespace-package=azure-cli-nspkg diff --git a/src/azure-cli-testsdk/setup.py b/src/azure-cli-testsdk/setup.py index 6d1cb2c9905..8b41ebcf473 100644 --- a/src/azure-cli-testsdk/setup.py +++ b/src/azure-cli-testsdk/setup.py @@ -7,12 +7,6 @@ from codecs import open from setuptools import setup -try: - from azure_bdist_wheel import cmdclass -except ImportError: - from distutils import log as logger - logger.warn("Wheel is not available, disabling bdist_wheel hook") - cmdclass = {} VERSION = "0.2.4" @@ -52,10 +46,7 @@ zip_safe=False, classifiers=CLASSIFIERS, packages=[ - 'azure', - 'azure.cli', 'azure.cli.testsdk' ], - install_requires=DEPENDENCIES, - cmdclass=cmdclass + install_requires=DEPENDENCIES ) diff --git a/src/azure-cli/MANIFEST.in b/src/azure-cli/MANIFEST.in index 4cbd0293f9a..df6177abb19 100644 --- a/src/azure-cli/MANIFEST.in +++ b/src/azure-cli/MANIFEST.in @@ -1,4 +1,8 @@ include LICENSE.txt include HISTORY.rst include README.rst -include azure_bdist_wheel.py +include azure_cli_bdist_wheel.py +include azure/__init__.py +include azure/cli/__init__.py +include azure/cli/__main__.py + diff --git a/src/azure-cli/azure/__init__.py b/src/azure-cli/azure/__init__.py index 73baee1e640..2ae78104e94 100644 --- a/src/azure-cli/azure/__init__.py +++ b/src/azure-cli/azure/__init__.py @@ -2,5 +2,4 @@ # 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__) +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/src/azure-cli/azure/cli/__init__.py b/src/azure-cli/azure/cli/__init__.py index 6a1336aa2a9..2ae78104e94 100644 --- a/src/azure-cli/azure/cli/__init__.py +++ b/src/azure-cli/azure/cli/__init__.py @@ -2,13 +2,4 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -'''The Azure Command-line tool. - -This tools provides a command-line interface to Azure's management and storage -APIs. -''' -import pkg_resources -pkg_resources.declare_namespace(__name__) - -__author__ = "Microsoft Corporation " -__version__ = "2.10.1" +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/src/azure-cli/azure/cli/__main__.py b/src/azure-cli/azure/cli/__main__.py index 06eef18cc6f..50b4b96af80 100644 --- a/src/azure-cli/azure/cli/__main__.py +++ b/src/azure-cli/azure/cli/__main__.py @@ -16,6 +16,9 @@ from knack.completion import ARGCOMPLETE_ENV_NAME from knack.log import get_logger +__author__ = "Microsoft Corporation " +__version__ = "2.10.1" + # A workaround for https://bugs.python.org/issue32502 (https://github.com/Azure/azure-cli/issues/5184) # If uuid1 raises ValueError, use uuid4 instead. diff --git a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py index 90ad3645317..2a9090a06ae 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py +++ b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py @@ -670,7 +670,7 @@ def test_k8s_install_kubectl_create_installation_dir(self, logger_mock, mock_url def test_k8s_install_kubelogin_emit_warnings(self, logger_mock, mock_url_retrieve): mock_url_retrieve.side_effect = create_kubelogin_zip try: - temp_dir = tempfile.mkdtemp() # tempfile.TemporaryDirectory() is no available on 2.7 + temp_dir = os.path.realpath(tempfile.mkdtemp()) # tempfile.TemporaryDirectory() is no available on 2.7 test_location = os.path.join(temp_dir, 'kubelogin') k8s_install_kubelogin(mock.MagicMock(), client_version='0.0.4', install_location=test_location) self.assertEqual(mock_url_retrieve.call_count, 1) @@ -696,9 +696,16 @@ def create_kubelogin_zip(file_url, download_path): import zipfile try: cwd = os.getcwd() - temp_dir = tempfile.mkdtemp() + temp_dir = os.path.realpath(tempfile.mkdtemp()) os.chdir(temp_dir) - bin_dir = 'bin/linux_amd64' + bin_dir = 'bin' + system = platform.system() + if system == 'Windows': + bin_dir += '/windows_amd64' + elif system == 'Linux': + bin_dir += '/linux_amd64' + elif system == 'Darwin': + bin_dir += '/darwin_amd64' os.makedirs(bin_dir) bin_location = os.path.join(bin_dir, 'kubelogin') open(bin_location, 'a').close() diff --git a/src/azure-cli/azure/cli/command_modules/config/tests/latest/test_config.py b/src/azure-cli/azure/cli/command_modules/config/tests/latest/test_config.py index e1fb7395d28..4b149d94385 100644 --- a/src/azure-cli/azure/cli/command_modules/config/tests/latest/test_config.py +++ b/src/azure-cli/azure/cli/command_modules/config/tests/latest/test_config.py @@ -23,7 +23,7 @@ def test_config(self): # test_option22 = test_value22 # C:\Users\{username}\AppData\Local\Temp - tempdir = tempfile.gettempdir() + tempdir = os.path.realpath(tempfile.gettempdir()) # call realpath to handle soft link problem on MAC original_path = os.getcwd() os.chdir(tempdir) print("Using temp dir: {}".format(tempdir)) diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_cli_version.py b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_cli_version.py index 9a4429f6bcd..e7e5f4524c0 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_cli_version.py +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_cli_version.py @@ -14,9 +14,7 @@ class VersionTest(ScenarioTest): def test_version(self): output = self.cmd('az version').get_output_in_json() self.assertIn('azure-cli', output) - self.assertIn('azure-cli-command-modules-nspkg', output) self.assertIn('azure-cli-core', output) - self.assertIn('azure-cli-nspkg', output) self.assertIn('azure-cli-telemetry', output) self.assertIn('azure-cli-testsdk', output) self.assertIn('extensions', output) diff --git a/src/azure-cli/azure/cli/command_modules/role/tests/latest/test_role.py b/src/azure-cli/azure/cli/command_modules/role/tests/latest/test_role.py index 80ad5adae39..91330079d0b 100644 --- a/src/azure-cli/azure/cli/command_modules/role/tests/latest/test_role.py +++ b/src/azure-cli/azure/cli/command_modules/role/tests/latest/test_role.py @@ -392,15 +392,15 @@ def test_role_assignment_handle_conflicted_assignments(self, resource_group): base_dir = os.path.abspath(os.curdir) try: - temp_dir = self.create_temp_dir() + temp_dir = os.path.realpath(self.create_temp_dir()) os.chdir(temp_dir) self.cmd('configure --default group={rg} --scope local') - local_defaults_config = self.cmd('configure --list-defaults --scope local', checks=[ - self.check('length([])', 1), - self.check('[0].name', 'group'), - self.check('[0].value', '{rg}') - ]).get_output_in_json() - self.assertTrue(temp_dir.lower() in local_defaults_config[0]['source'].lower()) + local_defaults_config = self.cmd('configure --list-defaults --scope local').get_output_in_json() + + self.assertGreaterEqual(len(local_defaults_config), 1) + actual = set([(x['name'], x['source'], x['value']) for x in local_defaults_config if x['name'] == 'group']) + expected = set([('group', os.path.join(temp_dir, '.azure', 'config'), self.kwargs['rg'])]) + self.assertEqual(actual, expected) # test role assignments on a resource group rg_id = self.cmd('group show -n {rg}').get_output_in_json()['id'] diff --git a/src/azure-cli/azure_bdist_wheel.py b/src/azure-cli/azure_bdist_wheel.py deleted file mode 100644 index 8a81d1b6177..00000000000 --- a/src/azure-cli/azure_bdist_wheel.py +++ /dev/null @@ -1,54 +0,0 @@ -#------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -#-------------------------------------------------------------------------- - -from distutils import log as logger -import os.path - -from wheel.bdist_wheel import bdist_wheel -class azure_bdist_wheel(bdist_wheel): - """The purpose of this class is to build wheel a little differently than the sdist, - without requiring to build the wheel from the sdist (i.e. you can build the wheel - directly from source). - """ - - description = "Create an Azure wheel distribution" - - user_options = bdist_wheel.user_options + \ - [('azure-namespace-package=', None, - "Name of the deepest nspkg used")] - - def initialize_options(self): - bdist_wheel.initialize_options(self) - self.azure_namespace_package = None - - def finalize_options(self): - bdist_wheel.finalize_options(self) - if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"): - raise ValueError("azure_namespace_package must finish by -nspkg") - - def run(self): - if not self.distribution.install_requires: - self.distribution.install_requires = [] - self.distribution.install_requires.append( - "{}>=2.0.0".format(self.azure_namespace_package)) - bdist_wheel.run(self) - - def write_record(self, bdist_dir, distinfo_dir): - if self.azure_namespace_package: - # Split and remove last part, assuming it's "nspkg" - subparts = self.azure_namespace_package.split('-')[0:-1] - folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))] - for azure_sub_package in folder_with_init: - init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py') - if os.path.isfile(init_file): - logger.info("manually remove {} while building the wheel".format(init_file)) - os.remove(init_file) - else: - raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file)) - bdist_wheel.write_record(self, bdist_dir, distinfo_dir) -cmdclass = { - 'bdist_wheel': azure_bdist_wheel, -} diff --git a/src/azure-cli/azure_cli_bdist_wheel.py b/src/azure-cli/azure_cli_bdist_wheel.py new file mode 100644 index 00000000000..8a2d18edb2e --- /dev/null +++ b/src/azure-cli/azure_cli_bdist_wheel.py @@ -0,0 +1,25 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +from distutils.command.build_py import build_py + + +class azure_cli_build_py(build_py): + + def initialize_options(self): + super(azure_cli_build_py, self).initialize_options() + self.extra_build_source_files = None + + def build_packages(self): + super(azure_cli_build_py, self).build_packages() + if self.extra_build_source_files: + package, module, module_file = self.extra_build_source_files.split(',') + self.build_module(module, module_file, package) + + +cmdclass = { + 'build_py': azure_cli_build_py, +} diff --git a/src/azure-cli/requirements.py3.Darwin.txt b/src/azure-cli/requirements.py3.Darwin.txt index 6a145a858ac..14ddc695764 100644 --- a/src/azure-cli/requirements.py3.Darwin.txt +++ b/src/azure-cli/requirements.py3.Darwin.txt @@ -5,12 +5,10 @@ argcomplete==1.11.1 asn1crypto==0.24.0 azure-batch==9.0.0 azure-cli==2.10.1 -azure-cli-command-modules-nspkg==2.0.3 azure-cli-core==2.10.1 -azure-cli-nspkg==3.0.4 -azure-cli-telemetry==1.0.4 +azure-cli-telemetry==1.0.5 azure-common==1.1.22 -azure-cosmos==3.1.0 +azure-cosmos==3.2.0 azure-datalake-store==0.0.48 azure-devtools==1.2.0 azure-functions-devops-build==0.0.22 @@ -59,7 +57,6 @@ azure-mgmt-monitor==0.11.0 azure-mgmt-msi==0.2.0 azure-mgmt-netapp==0.11.0 azure-mgmt-network==11.0.0 -azure-mgmt-nspkg==3.0.2 azure-mgmt-policyinsights==0.5.0 azure-mgmt-privatedns==0.1.0 azure-mgmt-rdbms==2.2.0 @@ -82,8 +79,7 @@ azure-mgmt-trafficmanager==0.51.0 azure-mgmt-web==0.47.0 azure-mgmt-synapse==0.3.0 azure-synapse-spark==0.2.0 -azure-multiapi-storage==0.3.2 -azure-nspkg==3.0.2 +azure-multiapi-storage==0.3.6 azure-loganalytics==0.1.0 azure-storage-common==1.4.2 bcrypt==3.1.7 diff --git a/src/azure-cli/requirements.py3.Linux.txt b/src/azure-cli/requirements.py3.Linux.txt index 6a145a858ac..14ddc695764 100644 --- a/src/azure-cli/requirements.py3.Linux.txt +++ b/src/azure-cli/requirements.py3.Linux.txt @@ -5,12 +5,10 @@ argcomplete==1.11.1 asn1crypto==0.24.0 azure-batch==9.0.0 azure-cli==2.10.1 -azure-cli-command-modules-nspkg==2.0.3 azure-cli-core==2.10.1 -azure-cli-nspkg==3.0.4 -azure-cli-telemetry==1.0.4 +azure-cli-telemetry==1.0.5 azure-common==1.1.22 -azure-cosmos==3.1.0 +azure-cosmos==3.2.0 azure-datalake-store==0.0.48 azure-devtools==1.2.0 azure-functions-devops-build==0.0.22 @@ -59,7 +57,6 @@ azure-mgmt-monitor==0.11.0 azure-mgmt-msi==0.2.0 azure-mgmt-netapp==0.11.0 azure-mgmt-network==11.0.0 -azure-mgmt-nspkg==3.0.2 azure-mgmt-policyinsights==0.5.0 azure-mgmt-privatedns==0.1.0 azure-mgmt-rdbms==2.2.0 @@ -82,8 +79,7 @@ azure-mgmt-trafficmanager==0.51.0 azure-mgmt-web==0.47.0 azure-mgmt-synapse==0.3.0 azure-synapse-spark==0.2.0 -azure-multiapi-storage==0.3.2 -azure-nspkg==3.0.2 +azure-multiapi-storage==0.3.6 azure-loganalytics==0.1.0 azure-storage-common==1.4.2 bcrypt==3.1.7 diff --git a/src/azure-cli/requirements.py3.windows.txt b/src/azure-cli/requirements.py3.windows.txt index 1e6b44df903..063d3882962 100644 --- a/src/azure-cli/requirements.py3.windows.txt +++ b/src/azure-cli/requirements.py3.windows.txt @@ -5,12 +5,10 @@ argcomplete==1.11.1 asn1crypto==0.24.0 azure-batch==9.0.0 azure-cli==2.10.1 -azure-cli-command-modules-nspkg==2.0.3 azure-cli-core==2.10.1 -azure-cli-nspkg==3.0.4 -azure-cli-telemetry==1.0.4 +azure-cli-telemetry==1.0.5 azure-common==1.1.22 -azure-cosmos==3.1.0 +azure-cosmos==3.2.0 azure-datalake-store==0.0.48 azure-devtools==1.2.0 azure-functions-devops-build==0.0.22 @@ -59,7 +57,6 @@ azure-mgmt-monitor==0.11.0 azure-mgmt-msi==0.2.0 azure-mgmt-netapp==0.11.0 azure-mgmt-network==11.0.0 -azure-mgmt-nspkg==3.0.2 azure-mgmt-policyinsights==0.5.0 azure-mgmt-privatedns==0.1.0 azure-mgmt-rdbms==2.2.0 @@ -82,8 +79,7 @@ azure-mgmt-trafficmanager==0.51.0 azure-mgmt-web==0.47.0 azure-mgmt-synapse==0.3.0 azure-synapse-spark==0.2.0 -azure-multiapi-storage==0.3.2 -azure-nspkg==3.0.2 +azure-multiapi-storage==0.3.6 azure-loganalytics==0.1.0 azure-storage-common==1.4.2 bcrypt==3.1.7 diff --git a/src/azure-cli/setup.cfg b/src/azure-cli/setup.cfg index 06af3bd4360..71550440584 100644 --- a/src/azure-cli/setup.cfg +++ b/src/azure-cli/setup.cfg @@ -1,2 +1,2 @@ -[bdist_wheel] -azure-namespace-package=azure-cli-nspkg +[build_py] +extra-build-source-files=azure.cli,__main__,azure/cli/__main__.py diff --git a/src/azure-cli/setup.py b/src/azure-cli/setup.py index e894b7e3886..8a11a00f5d8 100644 --- a/src/azure-cli/setup.py +++ b/src/azure-cli/setup.py @@ -11,7 +11,7 @@ import sys try: - from azure_bdist_wheel import cmdclass + from azure_cli_bdist_wheel import cmdclass except ImportError: from distutils import log as logger @@ -22,7 +22,7 @@ # If we have source, validate that our version numbers match # This should prevent uploading releases with mismatched versions. try: - with open('azure/cli/__init__.py', 'r', encoding='utf-8') as f: + with open('azure/cli/__main__.py', 'r', encoding='utf-8') as f: content = f.read() except OSError: pass @@ -31,7 +31,7 @@ m = re.search(r'__version__\s*=\s*[\'"](.+?)[\'"]', content) if not m: - print('Could not find __version__ in azure/cli/__init__.py') + print('Could not find __version__ in azure/cli/__main__.py') sys.exit(1) if m.group(1) != VERSION: print('Expected __version__ = "{}"; found "{}"'.format(VERSION, m.group(1))) @@ -52,9 +52,7 @@ DEPENDENCIES = [ 'antlr4-python3-runtime~=4.7.2', 'azure-batch~=9.0', - 'azure-cli-command_modules-nspkg~=2.0', 'azure-cli-core=={}.*'.format(VERSION), - 'azure-cli-nspkg~=3.0,>=3.0.3', 'azure-cosmos~=3.0,>=3.0.2', 'azure-datalake-store~=0.0.48', 'azure-functions-devops-build~=0.0.22', @@ -124,7 +122,7 @@ 'azure-mgmt-web~=0.47.0', 'azure-mgmt-synapse~=0.3.0', 'azure-synapse-spark~=0.2.0', - 'azure-multiapi-storage~=0.3.2', + 'azure-multiapi-storage~=0.3.6', 'azure-loganalytics~=0.1.0', 'azure-storage-common~=1.4', 'cryptography>=2.3.1,<3.0.0', @@ -166,10 +164,9 @@ 'az.completion.sh', 'az.bat', ], - packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), + packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests", "azure", "azure.cli"]), install_requires=DEPENDENCIES, package_data={ - 'azure.cli.core': ['auth_landing_pages/*.html'], 'azure.cli.command_modules.acr': ['*.json'], 'azure.cli.command_modules.botservice': ['*.json', '*.config'], 'azure.cli.command_modules.monitor.operations': ['autoscale-parameters-template.json'], diff --git a/tools/automation/style/__init__.py b/tools/automation/style/__init__.py index 52932960dce..0b1e99788c6 100644 --- a/tools/automation/style/__init__.py +++ b/tools/automation/style/__init__.py @@ -59,7 +59,7 @@ def define_arguments(parser): help='Run pylint') parser.add_argument('--module', dest='modules', action='append', help='The modules on which the style check should run. Accept short names, ' - 'except azure-cli, azure-cli-core and azure-cli-nspkg') + 'except azure-cli and azure-cli-core') def main_style(args):