forked from Azure/azure-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
137 lines (122 loc) · 4.41 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/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 __future__ import print_function
import os
import sys
from codecs import open
from setuptools import setup
VERSION = '0.0.1.dev0'
DISABLE_POST_INSTALL = os.environ.get('AZURE_CLI_DISABLE_POST_INSTALL')
PRIVATE_PYPI_URL_ENV_NAME = 'AZURE_CLI_PRIVATE_PYPI_URL'
PRIVATE_PYPI_URL = os.environ.get(PRIVATE_PYPI_URL_ENV_NAME)
PRIVATE_PYPI_HOST_ENV_NAME = 'AZURE_CLI_PRIVATE_PYPI_HOST'
PRIVATE_PYPI_HOST = os.environ.get(PRIVATE_PYPI_HOST_ENV_NAME)
INSTALL_FROM_PRIVATE = bool(PRIVATE_PYPI_URL and PRIVATE_PYPI_HOST)
# If we have source, validate that our version numbers match
# This should prevent uploading releases with mismatched versions.
try:
with open('src/azure/cli/__init__.py', 'r', encoding='utf-8') as f:
content = f.read()
except OSError:
pass
else:
import re, sys
m = re.search(r'__version__\s*=\s*[\'"](.+?)[\'"]', content)
if not m:
print('Could not find __version__ in azure/cli/__init__.py')
sys.exit(1)
if m.group(1) != VERSION:
print('Expected __version__ = "{}"; found "{}"'.format(VERSION, m.group(1)))
sys.exit(1)
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 :: MIT License',
]
DEPENDENCIES = [
'adal>=0.4.0',
'applicationinsights',
'argcomplete>=1.3.0',
'azure==2.0.0rc5',
'colorama',
'jmespath',
'msrest>=0.4.0',
'msrestazure>=0.4.0',
'pip',
'pygments',
'pyyaml',
'requests',
'six',
]
if sys.version_info < (3, 4):
DEPENDENCIES.append('enum34')
if sys.version_info < (2, 7, 9):
DEPENDENCIES.append('pyopenssl')
DEPENDENCIES.append('ndg-httpsclient')
DEPENDENCIES.append('pyasn1')
with open('README.rst', 'r', encoding='utf-8') as f:
README = f.read()
from setuptools.command.install import install
import pip
def _post_install(dir):
from subprocess import check_call
# Upgrade/update will install if it doesn't exist.
# We do this so these components are updated when the user updates the CLI.
if INSTALL_FROM_PRIVATE:
# use private PyPI server.
if not PRIVATE_PYPI_URL:
raise RuntimeError('{} environment variable not set.'.format(PRIVATE_PYPI_URL_ENV_NAME))
if not PRIVATE_PYPI_HOST:
raise RuntimeError('{} environment variable not set.'.format(PRIVATE_PYPI_HOST_ENV_NAME))
pip.main(['install', '--upgrade', 'azure-cli-component', '--extra-index-url',
PRIVATE_PYPI_URL, '--trusted-host', PRIVATE_PYPI_HOST,
'--disable-pip-version-check'])
check_call(['az', 'component', 'update', '-n', 'profile', '-p'])
else:
pip.main(['install', '--upgrade', 'azure-cli-component', '--disable-pip-version-check'])
check_call(['az', 'component', 'update', '-n', 'profile'])
class OnInstall(install):
def run(self):
install.run(self)
if not DISABLE_POST_INSTALL:
self.execute(_post_install, (self.install_lib,),
msg="Running post install task")
setup(
name='azure-cli',
version=VERSION,
description='Microsoft Azure Command-Line Tools',
long_description=README,
license='MIT',
author='Microsoft Corporation',
author_email='[email protected]',
url='https://github.com/Azure/azure-cli',
zip_safe=False,
classifiers=CLASSIFIERS,
scripts=[
'az',
'az.completion.sh',
'az.bat',
],
package_dir = {'':'src'},
namespace_packages = ['azure'],
packages=[
'azure.cli',
'azure.cli.commands',
'azure.cli.command_modules',
'azure.cli.extensions',
'azure.cli.utils',
],
package_data={'azure.cli': ['locale/**/*.txt']},
install_requires=DEPENDENCIES,
cmdclass={'install': OnInstall},
)