- Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathsetup.py
62 lines (49 loc) · 2.21 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
#!/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__ importprint_function
importos.path
importglob
importcopy
importsys
importrunpy
root_folder=os.path.abspath(os.path.dirname(__file__))
# pull in any packages that exist in the root directory
packages= {('.', os.path.dirname(p)) forpinglob.glob('azure*/setup.py')}
# Handle the SDK folder as well
packages.update({tuple(os.path.dirname(f).rsplit(os.sep, 1)) forfinglob.glob('sdk/*/azure*/setup.py')})
# [(base_folder, package_name), ...] to {package_name: base_folder, ...}
packages= {package_name: base_folderfor (base_folder, package_name) inpackages}
# Extract nspkg and sort nspkg by number of "-"
nspkg_packages= [pforpinpackages.keys() if"nspkg"inp]
nspkg_packages.sort(key=lambdax: len([cforcinxifc=='-']))
# Meta-packages to ignore
meta_package= ['azure-keyvault', 'azure-mgmt', 'azure', 'azure-storage']
# content packages are packages that are not meta nor nspkg
content_package=sorted([pforpinpackages.keys() ifpnotinmeta_package+nspkg_packages])
# Move azure-common at the beginning, it's important this goes first
content_package.remove("azure-common")
content_package.insert(0, "azure-common")
# Package final:
if"install"insys.argv:
packages_for_installation=content_package
else:
packages_for_installation=nspkg_packages+content_package
forpkg_nameinpackages_for_installation:
pkg_setup_folder=os.path.join(root_folder, packages[pkg_name], pkg_name)
pkg_setup_path=os.path.join(pkg_setup_folder, 'setup.py')
try:
saved_dir=os.getcwd()
saved_syspath=sys.path
os.chdir(pkg_setup_folder)
sys.path= [pkg_setup_folder] +copy.copy(saved_syspath)
print("Start ", pkg_setup_path)
result=runpy.run_path(pkg_setup_path)
exceptExceptionase:
print(e, file=sys.stderr)
finally:
os.chdir(saved_dir)
sys.path=saved_syspath