Skip to content

Commit 0be2180

Browse files
authored
Properly resolve the various directories in root setup.py (#5449)
* resetting to upstream master to dump erroneous commits, updating setup.py * making setup order predictable
1 parent c00da80 commit 0be2180

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

setup.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,35 @@
1515

1616
root_folder = os.path.abspath(os.path.dirname(__file__))
1717

18-
packages = [os.path.dirname(p) for p in (glob.glob('azure*/setup.py') + glob.glob('sdk/*/azure*/setup.py'))]
19-
20-
# "install" is used by ReadTheDocs, do not install "nspkg"
18+
# pull in any packages that exist in the root directory
19+
packages = {('.', os.path.dirname(p)) for p in glob.glob('azure*/setup.py')}
20+
# Handle the SDK folder as well
21+
packages.update({tuple(os.path.dirname(f).rsplit(os.sep, 1)) for f in glob.glob('sdk/*/azure*/setup.py')})
22+
# [(base_folder, package_name), ...] to {package_name: base_folder, ...}
23+
packages = {package_name: base_folder for (base_folder, package_name) in packages}
2124

2225
# Extract nspkg and sort nspkg by number of "-"
23-
nspkg_packages = [p for p in packages if "nspkg" in p]
26+
nspkg_packages = [p for p in packages.keys() if "nspkg" in p]
2427
nspkg_packages.sort(key = lambda x: len([c for c in x if c == '-']))
2528

2629
# Manually push meta-packages at the end, in reverse dependency order
2730
meta_package = ['azure-mgmt', 'azure']
2831

29-
# So content packages are:
30-
content_package = [p for p in packages if p not in meta_package+nspkg_packages]
31-
# Move azure-common at the beginning
32+
# content packages are packages that are not meta nor nspkg
33+
content_package = sorted([p for p in packages.keys() if p not in meta_package+nspkg_packages])
34+
35+
# Move azure-common at the beginning, it's important this goes first
3236
content_package.remove("azure-common")
3337
content_package.insert(0, "azure-common")
3438

3539
# Package final:
3640
if "install" in sys.argv:
37-
packages = content_package
41+
packages_for_installation = content_package
3842
else:
39-
packages = nspkg_packages + content_package + meta_package
43+
packages_for_installation = nspkg_packages + content_package + meta_package
4044

41-
for pkg_name in packages:
42-
pkg_setup_folder = os.path.join(root_folder, pkg_name)
45+
for pkg_name in packages_for_installation:
46+
pkg_setup_folder = os.path.join(root_folder, packages[pkg_name], pkg_name)
4347
pkg_setup_path = os.path.join(pkg_setup_folder, 'setup.py')
4448

4549
try:

0 commit comments

Comments
 (0)