Skip to content

Commit eff520c

Browse files
committed
Create all component packages
1 parent e309d4e commit eff520c

File tree

62 files changed

+724
-50
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+724
-50
lines changed

MANIFEST.in

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
include *.rst
2-
exclude src/azure/__init__.py

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
applicationinsights==0.10.0
22
azure==2.0.0rc1
33
jmespath
4+
pip
45
mock==1.3.0
56
pylint==1.5.4
67
six==1.10.0

setup.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from codecs import open
2020
from setuptools import setup
2121

22-
VERSION = '0.0.1'
22+
VERSION = '0.0.3.dev0'
2323

2424
# If we have source, validate that our version numbers match
2525
# This should prevent uploading releases with mismatched versions.
@@ -56,10 +56,12 @@
5656

5757
DEPENDENCIES = [
5858
'applicationinsights',
59-
'azure==2.0.0rc1',
59+
'msrest',
6060
'six',
6161
'jmespath',
62-
'adal==0.2.0' #from internal index server.
62+
'pip',
63+
# 'azure-cli-components==0.0.3.dev0',
64+
# 'azure-cli-login==0.0.3.dev0',
6365
]
6466

6567
with open('README.rst', 'r', encoding='utf-8') as f:
@@ -82,10 +84,17 @@
8284
],
8385
package_dir = {'':'src'},
8486
packages=[
87+
'azure',
8588
'azure.cli',
8689
'azure.cli.commands',
90+
'azure.cli.command_modules',
8791
'azure.cli.extensions',
8892
],
8993
package_data={'azure.cli': ['locale/**/*.txt']},
9094
install_requires=DEPENDENCIES,
95+
extras_require={
96+
':python_version < "3.4"': [
97+
'enum34',
98+
],
99+
},
91100
)

src/azure/cli/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
__import__('pkg_resources').declare_namespace(__name__)
12
'''The Azure Command-line tool.
23
34
This tools provides a command-line interface to Azure's management and storage
45
APIs.
56
'''
67

78
__author__ = "Microsoft Corporation <[email protected]>"
8-
__version__ = "0.0.1"
9+
__version__ = "0.0.3.dev0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__import__('pkg_resources').declare_namespace(__name__)

src/azure/cli/commands/__init__.py

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
from .._argparse import IncorrectUsageError
1+
from pip import get_installed_distributions
2+
3+
from .._argparse import IncorrectUsageError
24
from .._logging import logger
35

4-
# TODO: Alternatively, simply scan the directory for all modules
5-
COMMAND_MODULES = [
6-
'account',
7-
'login',
8-
'logout',
9-
'network',
10-
'resource',
11-
'storage',
12-
'vm',
13-
]
6+
# Find our command modules, they start with 'azure-cli-'
7+
INSTALLED_COMMAND_MODULES = [dist.key.replace('azure-cli-', '') for dist in get_installed_distributions(local_only=False) if dist.key.startswith('azure-cli-')]
148

159
_COMMANDS = {}
1610

@@ -48,15 +42,16 @@ def add_to_parser(parser, command_name=None):
4842
loaded = False
4943
if command_name:
5044
try:
51-
__import__('azure.cli.commands.' + command_name)
45+
# Try and load the installed command module
46+
__import__('azure.cli.command_modules.'+command_name)
5247
loaded = True
5348
except ImportError:
54-
# Unknown command - we'll load all below
49+
# Unknown command - we'll load all installed modules below
5550
pass
5651

5752
if not loaded:
58-
for mod in COMMAND_MODULES:
59-
__import__('azure.cli.commands.' + mod)
53+
for installed_mods in INSTALLED_COMMAND_MODULES:
54+
__import__('azure.cli.command_modules.'+installed_mods)
6055
loaded = True
6156

6257
for handler, info in _COMMANDS.items():
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Microsoft Azure CLI 'account' Command Module
2+
==================================
3+
4+
This package is for the 'account' module.
5+
i.e. 'az account'
6+
7+
This package has [not] been tested [much] with Python 2.7, 3.4 and 3.5.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__import__('pkg_resources').declare_namespace(__name__)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__import__('pkg_resources').declare_namespace(__name__)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__import__('pkg_resources').declare_namespace(__name__)

src/azure/cli/commands/account.py src/command_modules/azure-cli-account/azure/cli/command_modules/account/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .._profile import Profile
2-
from ..commands import command, description, option
3-
from .._locale import L
1+
from azure.cli._profile import Profile
2+
from azure.cli.commands import command, description, option
3+
from azure.cli._locale import L
44

55
@command('account list')
66
@description(L('List the imported subscriptions.'))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
azure-cli
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python
2+
3+
#-------------------------------------------------------------------------
4+
# Copyright (c) Microsoft. All rights reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#--------------------------------------------------------------------------
17+
18+
from codecs import open
19+
from setuptools import setup
20+
21+
VERSION = '0.0.3.dev0'
22+
23+
# The full list of classifiers is available at
24+
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
25+
CLASSIFIERS = [
26+
'Development Status :: 3 - Alpha',
27+
'Intended Audience :: Developers',
28+
'Intended Audience :: System Administrators',
29+
'Programming Language :: Python',
30+
'Programming Language :: Python :: 2',
31+
'Programming Language :: Python :: 2.7',
32+
'Programming Language :: Python :: 3',
33+
'Programming Language :: Python :: 3.4',
34+
'Programming Language :: Python :: 3.5',
35+
#'License :: OSI Approved :: Apache Software License',
36+
#'License :: OSI Approved :: MIT License',
37+
]
38+
39+
DEPENDENCIES = [
40+
'azure-cli',
41+
]
42+
43+
with open('README.rst', 'r', encoding='utf-8') as f:
44+
README = f.read()
45+
46+
setup(
47+
name='azure-cli-account',
48+
version=VERSION,
49+
description='Microsoft Azure Command-Line Tools',
50+
long_description=README,
51+
license='TBD',
52+
author='Microsoft Corporation',
53+
author_email='[email protected]',
54+
url='https://github.com/Azure/azure-cli',
55+
classifiers=CLASSIFIERS,
56+
namespace_packages = ['azure.cli.command_modules'],
57+
packages=[
58+
'azure.cli.command_modules.account',
59+
],
60+
install_requires=DEPENDENCIES,
61+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Microsoft Azure CLI 'components' Command Module
2+
==================================
3+
4+
This package is for the 'components' module.
5+
i.e. 'az components'
6+
7+
This package has [not] been tested [much] with Python 2.7, 3.4 and 3.5.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__import__('pkg_resources').declare_namespace(__name__)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__import__('pkg_resources').declare_namespace(__name__)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__import__('pkg_resources').declare_namespace(__name__)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import pip
2+
from azure.cli.commands import command, description, option
3+
from azure.cli._locale import L
4+
5+
# TODO:: Support installing/removing of a specific version
6+
7+
@command('components list')
8+
@description(L('List the installed components.'))
9+
def list_components(args, unexpected): #pylint: disable=unused-argument
10+
return sorted(["%s (%s)" % (dist.key.replace('azure-cli-', ''), dist.version) for dist in pip.get_installed_distributions(local_only=False) if dist.key.startswith('azure-cli-')])
11+
12+
# @command('components check')
13+
# @description(L('Check a component for an update'))
14+
# @option('--name -n <name>')
15+
# def install_component(args, unexpected): #pylint: disable=unused-argument
16+
# component_name = args.get('name')
17+
# if not component_name:
18+
# # Show all
19+
# pip.main(['list', '--pre', '--outdated', '--isolated',
20+
# '--trusted-host', '40.112.211.51',
21+
# '--extra-index-url', 'http://40.112.211.51:8080/'])
22+
# else:
23+
# try:
24+
# __import__('azure.cli.command_modules.'+component_name+'.__main__')
25+
# # Check for updates
26+
# pip.main(['list', '--pre', '--outdated', '--isolated',
27+
# '--trusted-host', '40.112.211.51',
28+
# '--find-links', 'http://40.112.211.51:8080/simple/azure-cli-'+component_name])
29+
# except ImportError:
30+
# raise RuntimeError("Component not installed.")
31+
32+
# @command('components install')
33+
# @description(L('Install a component'))
34+
# @option('--name -n <name>', required=True)
35+
# @option('--version -v <version>')
36+
# def install_component(args, unexpected): #pylint: disable=unused-argument
37+
# component_name = args.get('name')
38+
# if not component_name:
39+
# raise RuntimeError("Specify a component name.")
40+
# try:
41+
# __import__('azure.cli.command_modules.'+component_name+'.__main__')
42+
# # Check for updates
43+
# pip.main(['list', '--pre', '--outdated', '--isolated',
44+
# '--trusted-host', '40.112.211.51',
45+
# '--find-links', 'http://40.112.211.51:8080/simple/azure-cli-'+component_name])
46+
# raise RuntimeError("Component already installed.")
47+
# except ImportError:
48+
# version_no = '=='+args.get('version') if args.get('version') else ''
49+
# pip.main(['install', '--quiet', '--isolated', '--disable-pip-version-check', 'azure-cli-'+component_name+version_no,
50+
# '--extra-index-url', 'http://40.112.211.51:8080/', '--trusted-host', '40.112.211.51'])
51+
52+
# @command('components update')
53+
# @description(L('Update a component'))
54+
# @option('--name -n <name>', required=True)
55+
# def update_component(args, unexpected): #pylint: disable=unused-argument
56+
# component_name = args.get('name')
57+
# if not component_name:
58+
# raise RuntimeError("Specify a component name.")
59+
# try:
60+
# __import__('azure.cli.command_modules.'+component_name+'.__main__')
61+
# pip.main(['install', '--quiet', '--isolated', '--disable-pip-version-check', '--upgrade', 'azure-cli-'+component_name,
62+
# '--extra-index-url', 'http://40.112.211.51:8080/', '--trusted-host', '40.112.211.51'])
63+
# except ImportError:
64+
# raise RuntimeError("Component not installed.")
65+
66+
# @command('components remove')
67+
# @description(L('Remove a component'))
68+
# @option('--name -n <name>', required=True)
69+
# def remove_component(args, unexpected): #pylint: disable=unused-argument
70+
# component_name = args.get('name')
71+
# if not component_name:
72+
# raise RuntimeError("Specify a component name.")
73+
# try:
74+
# __import__('azure.cli.command_modules.'+component_name+'.__main__')
75+
# # The component is installed so we can uninstall it
76+
# pip.main(['uninstall', '--quiet', '--isolated', '--yes', 'azure-cli-'+component_name])
77+
# except ImportError:
78+
# raise RuntimeError("Component not installed.")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
azure-cli
2+
pip
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env python
2+
3+
#-------------------------------------------------------------------------
4+
# Copyright (c) Microsoft. All rights reserved.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#--------------------------------------------------------------------------
17+
18+
from codecs import open
19+
from setuptools import setup
20+
21+
VERSION = '0.0.3.dev0'
22+
23+
# The full list of classifiers is available at
24+
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
25+
CLASSIFIERS = [
26+
'Development Status :: 3 - Alpha',
27+
'Intended Audience :: Developers',
28+
'Intended Audience :: System Administrators',
29+
'Programming Language :: Python',
30+
'Programming Language :: Python :: 2',
31+
'Programming Language :: Python :: 2.7',
32+
'Programming Language :: Python :: 3',
33+
'Programming Language :: Python :: 3.4',
34+
'Programming Language :: Python :: 3.5',
35+
#'License :: OSI Approved :: Apache Software License',
36+
#'License :: OSI Approved :: MIT License',
37+
]
38+
39+
DEPENDENCIES = [
40+
'azure-cli',
41+
'pip',
42+
]
43+
44+
with open('README.rst', 'r', encoding='utf-8') as f:
45+
README = f.read()
46+
47+
setup(
48+
name='azure-cli-components',
49+
version=VERSION,
50+
description='Microsoft Azure Command-Line Tools',
51+
long_description=README,
52+
license='TBD',
53+
author='Microsoft Corporation',
54+
author_email='[email protected]',
55+
url='https://github.com/Azure/azure-cli',
56+
classifiers=CLASSIFIERS,
57+
namespace_packages = ['azure.cli.command_modules'],
58+
packages=[
59+
'azure.cli.command_modules.components',
60+
],
61+
install_requires=DEPENDENCIES,
62+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Microsoft Azure CLI 'login' Command Module
2+
==================================
3+
4+
This package is for the 'login' module.
5+
i.e. 'az login'
6+
7+
This package has [not] been tested [much] with Python 2.7, 3.4 and 3.5.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__import__('pkg_resources').declare_namespace(__name__)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__import__('pkg_resources').declare_namespace(__name__)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__import__('pkg_resources').declare_namespace(__name__)

src/azure/cli/commands/login.py src/command_modules/azure-cli-login/azure/cli/command_modules/login/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import print_function
1+
from __future__ import print_function
22
from msrest.authentication import BasicTokenAuthentication
33
from adal import (acquire_token_with_username_password,
44
acquire_token_with_client_credentials,
@@ -7,11 +7,11 @@
77
from azure.mgmt.resource.subscriptions import (SubscriptionClient,
88
SubscriptionClientConfiguration)
99

10-
from .._profile import Profile
11-
from ..commands import command, description, option
10+
from azure.cli._profile import Profile
11+
from azure.cli.commands import command, description, option
1212
#TODO: update adal-python to support it
13-
#from .._debug import should_disable_connection_verify
14-
from .._locale import L
13+
#from azure.cli._debug import should_disable_connection_verify
14+
from azure.cli._locale import L
1515

1616
@command('login')
1717
@description(L('log in to an Azure subscription using Active Directory Organization Id'))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
azure-cli
2+
azure==2.0.0rc1
3+
4+
#Same as: -e git+https://github.com/yugangw-msft/azure-activedirectory-library-for-python.git@device#egg=azure-activedirectory-library-for-python
5+
http://40.112.211.51:8080/packages/adal-0.2.0.zip

0 commit comments

Comments
 (0)