2017-08-09 22:09:35 +03:00
|
|
|
#!/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 sys
|
|
|
|
import glob
|
|
|
|
import os
|
|
|
|
from subprocess import check_call, CalledProcessError
|
|
|
|
|
|
|
|
root_dir = os.path.abspath(os.path.join(os.path.abspath(__file__), '..', '..'))
|
|
|
|
|
|
|
|
|
2018-02-28 19:27:06 +03:00
|
|
|
def pip_command(command):
|
2017-08-09 22:09:35 +03:00
|
|
|
try:
|
|
|
|
print('Executing: ' + command)
|
2018-02-28 19:27:06 +03:00
|
|
|
check_call([sys.executable, '-m', 'pip'] + command.split(), cwd=root_dir)
|
2017-08-09 22:09:35 +03:00
|
|
|
print()
|
|
|
|
except CalledProcessError as err:
|
|
|
|
print(err, file=sys.stderr)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
packages = [os.path.dirname(p) for p in glob.glob('azure*/setup.py')]
|
|
|
|
|
|
|
|
# Extract nspkg and sort nspkg by number of "-"
|
|
|
|
nspkg_packages = [p for p in packages if "nspkg" in p]
|
|
|
|
nspkg_packages.sort(key = lambda x: len([c for c in x if c == '-']))
|
|
|
|
|
|
|
|
# Consider "azure-common" as a power nspkg : has to be installed after nspkg
|
|
|
|
nspkg_packages.append("azure-common")
|
|
|
|
|
|
|
|
# Manually push meta-packages at the end, in reverse dependency order
|
|
|
|
meta_packages = ['azure-mgmt', 'azure']
|
|
|
|
|
|
|
|
content_packages = [p for p in packages if p not in nspkg_packages+meta_packages]
|
|
|
|
|
|
|
|
print('Running dev setup...')
|
|
|
|
print('Root directory \'{}\'\n'.format(root_dir))
|
|
|
|
|
2018-09-01 01:29:10 +03:00
|
|
|
# install private whls if there are any
|
|
|
|
privates_dir = os.path.join(root_dir, 'privates')
|
|
|
|
if os.path.isdir(privates_dir) and os.listdir(privates_dir):
|
|
|
|
whl_list = ' '.join([os.path.join(privates_dir, f) for f in os.listdir(privates_dir)])
|
|
|
|
pip_command('install {}'.format(whl_list))
|
|
|
|
|
2017-08-09 22:09:35 +03:00
|
|
|
# install packages
|
|
|
|
for package_list in [nspkg_packages, content_packages]:
|
|
|
|
for package_name in package_list:
|
2018-02-28 19:27:06 +03:00
|
|
|
pip_command('install -e {}'.format(package_name))
|
2017-08-09 22:09:35 +03:00
|
|
|
|
|
|
|
# Ensure that the site package's azure/__init__.py has the old style namespace
|
|
|
|
# package declaration by installing the old namespace package
|
2018-02-28 19:27:06 +03:00
|
|
|
pip_command('install --force-reinstall azure-mgmt-nspkg==1.0.0')
|
2018-06-12 18:26:36 +03:00
|
|
|
pip_command('install --force-reinstall azure-nspkg==1.0.0')
|
2017-08-09 22:09:35 +03:00
|
|
|
print('Finished dev setup.')
|