Skip to content

Commit

Permalink
Create all component packages
Browse files Browse the repository at this point in the history
  • Loading branch information
derekbekoe committed Mar 25, 2016
1 parent e309d4e commit eff520c
Show file tree
Hide file tree
Showing 62 changed files with 724 additions and 50 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
include *.rst
exclude src/azure/__init__.py
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
applicationinsights==0.10.0
azure==2.0.0rc1
jmespath
pip
mock==1.3.0
pylint==1.5.4
six==1.10.0
Expand Down
15 changes: 12 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from codecs import open
from setuptools import setup

VERSION = '0.0.1'
VERSION = '0.0.3.dev0'

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

DEPENDENCIES = [
'applicationinsights',
'azure==2.0.0rc1',
'msrest',
'six',
'jmespath',
'adal==0.2.0' #from internal index server.
'pip',
# 'azure-cli-components==0.0.3.dev0',
# 'azure-cli-login==0.0.3.dev0',
]

with open('README.rst', 'r', encoding='utf-8') as f:
Expand All @@ -82,10 +84,17 @@
],
package_dir = {'':'src'},
packages=[
'azure',
'azure.cli',
'azure.cli.commands',
'azure.cli.command_modules',
'azure.cli.extensions',
],
package_data={'azure.cli': ['locale/**/*.txt']},
install_requires=DEPENDENCIES,
extras_require={
':python_version < "3.4"': [
'enum34',
],
},
)
3 changes: 2 additions & 1 deletion src/azure/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
__import__('pkg_resources').declare_namespace(__name__)
'''The Azure Command-line tool.
This tools provides a command-line interface to Azure's management and storage
APIs.
'''

__author__ = "Microsoft Corporation <[email protected]>"
__version__ = "0.0.1"
__version__ = "0.0.3.dev0"
1 change: 1 addition & 0 deletions src/azure/cli/command_modules/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
25 changes: 10 additions & 15 deletions src/azure/cli/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
from .._argparse import IncorrectUsageError
from pip import get_installed_distributions

from .._argparse import IncorrectUsageError
from .._logging import logger

# TODO: Alternatively, simply scan the directory for all modules
COMMAND_MODULES = [
'account',
'login',
'logout',
'network',
'resource',
'storage',
'vm',
]
# Find our command modules, they start with 'azure-cli-'
INSTALLED_COMMAND_MODULES = [dist.key.replace('azure-cli-', '') for dist in get_installed_distributions(local_only=False) if dist.key.startswith('azure-cli-')]

_COMMANDS = {}

Expand Down Expand Up @@ -48,15 +42,16 @@ def add_to_parser(parser, command_name=None):
loaded = False
if command_name:
try:
__import__('azure.cli.commands.' + command_name)
# Try and load the installed command module
__import__('azure.cli.command_modules.'+command_name)
loaded = True
except ImportError:
# Unknown command - we'll load all below
# Unknown command - we'll load all installed modules below
pass

if not loaded:
for mod in COMMAND_MODULES:
__import__('azure.cli.commands.' + mod)
for installed_mods in INSTALLED_COMMAND_MODULES:
__import__('azure.cli.command_modules.'+installed_mods)
loaded = True

for handler, info in _COMMANDS.items():
Expand Down
7 changes: 7 additions & 0 deletions src/command_modules/azure-cli-account/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Microsoft Azure CLI 'account' Command Module
==================================

This package is for the 'account' module.
i.e. 'az account'

This package has [not] been tested [much] with Python 2.7, 3.4 and 3.5.
1 change: 1 addition & 0 deletions src/command_modules/azure-cli-account/azure/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .._profile import Profile
from ..commands import command, description, option
from .._locale import L
from azure.cli._profile import Profile
from azure.cli.commands import command, description, option
from azure.cli._locale import L

@command('account list')
@description(L('List the imported subscriptions.'))
Expand Down
1 change: 1 addition & 0 deletions src/command_modules/azure-cli-account/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
azure-cli
61 changes: 61 additions & 0 deletions src/command_modules/azure-cli-account/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python

#-------------------------------------------------------------------------
# Copyright (c) Microsoft. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#--------------------------------------------------------------------------

from codecs import open
from setuptools import setup

VERSION = '0.0.3.dev0'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
CLASSIFIERS = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
#'License :: OSI Approved :: Apache Software License',
#'License :: OSI Approved :: MIT License',
]

DEPENDENCIES = [
'azure-cli',
]

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

setup(
name='azure-cli-account',
version=VERSION,
description='Microsoft Azure Command-Line Tools',
long_description=README,
license='TBD',
author='Microsoft Corporation',
author_email='[email protected]',
url='https://github.com/Azure/azure-cli',
classifiers=CLASSIFIERS,
namespace_packages = ['azure.cli.command_modules'],
packages=[
'azure.cli.command_modules.account',
],
install_requires=DEPENDENCIES,
)
7 changes: 7 additions & 0 deletions src/command_modules/azure-cli-components/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Microsoft Azure CLI 'components' Command Module
==================================

This package is for the 'components' module.
i.e. 'az components'

This package has [not] been tested [much] with Python 2.7, 3.4 and 3.5.
1 change: 1 addition & 0 deletions src/command_modules/azure-cli-components/azure/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import pip
from azure.cli.commands import command, description, option
from azure.cli._locale import L

# TODO:: Support installing/removing of a specific version

@command('components list')
@description(L('List the installed components.'))
def list_components(args, unexpected): #pylint: disable=unused-argument
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-')])

# @command('components check')
# @description(L('Check a component for an update'))
# @option('--name -n <name>')
# def install_component(args, unexpected): #pylint: disable=unused-argument
# component_name = args.get('name')
# if not component_name:
# # Show all
# pip.main(['list', '--pre', '--outdated', '--isolated',
# '--trusted-host', '40.112.211.51',
# '--extra-index-url', 'http://40.112.211.51:8080/'])
# else:
# try:
# __import__('azure.cli.command_modules.'+component_name+'.__main__')
# # Check for updates
# pip.main(['list', '--pre', '--outdated', '--isolated',
# '--trusted-host', '40.112.211.51',
# '--find-links', 'http://40.112.211.51:8080/simple/azure-cli-'+component_name])
# except ImportError:
# raise RuntimeError("Component not installed.")

# @command('components install')
# @description(L('Install a component'))
# @option('--name -n <name>', required=True)
# @option('--version -v <version>')
# def install_component(args, unexpected): #pylint: disable=unused-argument
# component_name = args.get('name')
# if not component_name:
# raise RuntimeError("Specify a component name.")
# try:
# __import__('azure.cli.command_modules.'+component_name+'.__main__')
# # Check for updates
# pip.main(['list', '--pre', '--outdated', '--isolated',
# '--trusted-host', '40.112.211.51',
# '--find-links', 'http://40.112.211.51:8080/simple/azure-cli-'+component_name])
# raise RuntimeError("Component already installed.")
# except ImportError:
# version_no = '=='+args.get('version') if args.get('version') else ''
# pip.main(['install', '--quiet', '--isolated', '--disable-pip-version-check', 'azure-cli-'+component_name+version_no,
# '--extra-index-url', 'http://40.112.211.51:8080/', '--trusted-host', '40.112.211.51'])

# @command('components update')
# @description(L('Update a component'))
# @option('--name -n <name>', required=True)
# def update_component(args, unexpected): #pylint: disable=unused-argument
# component_name = args.get('name')
# if not component_name:
# raise RuntimeError("Specify a component name.")
# try:
# __import__('azure.cli.command_modules.'+component_name+'.__main__')
# pip.main(['install', '--quiet', '--isolated', '--disable-pip-version-check', '--upgrade', 'azure-cli-'+component_name,
# '--extra-index-url', 'http://40.112.211.51:8080/', '--trusted-host', '40.112.211.51'])
# except ImportError:
# raise RuntimeError("Component not installed.")

# @command('components remove')
# @description(L('Remove a component'))
# @option('--name -n <name>', required=True)
# def remove_component(args, unexpected): #pylint: disable=unused-argument
# component_name = args.get('name')
# if not component_name:
# raise RuntimeError("Specify a component name.")
# try:
# __import__('azure.cli.command_modules.'+component_name+'.__main__')
# # The component is installed so we can uninstall it
# pip.main(['uninstall', '--quiet', '--isolated', '--yes', 'azure-cli-'+component_name])
# except ImportError:
# raise RuntimeError("Component not installed.")
2 changes: 2 additions & 0 deletions src/command_modules/azure-cli-components/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
azure-cli
pip
62 changes: 62 additions & 0 deletions src/command_modules/azure-cli-components/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python

#-------------------------------------------------------------------------
# Copyright (c) Microsoft. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#--------------------------------------------------------------------------

from codecs import open
from setuptools import setup

VERSION = '0.0.3.dev0'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
CLASSIFIERS = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
#'License :: OSI Approved :: Apache Software License',
#'License :: OSI Approved :: MIT License',
]

DEPENDENCIES = [
'azure-cli',
'pip',
]

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

setup(
name='azure-cli-components',
version=VERSION,
description='Microsoft Azure Command-Line Tools',
long_description=README,
license='TBD',
author='Microsoft Corporation',
author_email='[email protected]',
url='https://github.com/Azure/azure-cli',
classifiers=CLASSIFIERS,
namespace_packages = ['azure.cli.command_modules'],
packages=[
'azure.cli.command_modules.components',
],
install_requires=DEPENDENCIES,
)
7 changes: 7 additions & 0 deletions src/command_modules/azure-cli-login/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Microsoft Azure CLI 'login' Command Module
==================================

This package is for the 'login' module.
i.e. 'az login'

This package has [not] been tested [much] with Python 2.7, 3.4 and 3.5.
1 change: 1 addition & 0 deletions src/command_modules/azure-cli-login/azure/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
1 change: 1 addition & 0 deletions src/command_modules/azure-cli-login/azure/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import print_function
from __future__ import print_function
from msrest.authentication import BasicTokenAuthentication
from adal import (acquire_token_with_username_password,
acquire_token_with_client_credentials,
Expand All @@ -7,11 +7,11 @@
from azure.mgmt.resource.subscriptions import (SubscriptionClient,
SubscriptionClientConfiguration)

from .._profile import Profile
from ..commands import command, description, option
from azure.cli._profile import Profile
from azure.cli.commands import command, description, option
#TODO: update adal-python to support it
#from .._debug import should_disable_connection_verify
from .._locale import L
#from azure.cli._debug import should_disable_connection_verify
from azure.cli._locale import L

@command('login')
@description(L('log in to an Azure subscription using Active Directory Organization Id'))
Expand Down
5 changes: 5 additions & 0 deletions src/command_modules/azure-cli-login/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
azure-cli
azure==2.0.0rc1

#Same as: -e git+https://github.com/yugangw-msft/azure-activedirectory-library-for-python.git@device#egg=azure-activedirectory-library-for-python
http://40.112.211.51:8080/packages/adal-0.2.0.zip
Loading

0 comments on commit eff520c

Please sign in to comment.