File: get_package_properties.py

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (69 lines) | stat: -rw-r--r-- 2,783 bytes parent folder | download
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
import argparse
import os
import re

from typing import Dict, List

from ci_tools.parsing import ParsedSetup

additional_pr_triggers: Dict[str, List[str]] = {
    "azure-core":[
        "/sdk/servicebus/azure-servicebus",
        "/sdk/eventhub/azure-eventhub",
        "/sdk/tables/azure-data-tables",
        "/sdk/appconfiguration/azure-appconfiguration",
        "/sdk/keyvault/azure-keyvault-keys",
        "/sdk/identity/azure-identity",
        "/sdk/core/azure-mgmt-core",
        "/sdk/core/azure-core-experimental",
        "/sdk/core/azure-core-tracing-opentelemetry",
        "/sdk/core/azure-core-tracing-opencensus",
        # todo: this currently won't be included, as azure-cosmos needs some special construction
        # related to windows only + emulator
        # "/sdk/cosmos/azure-cosmos",
        "/sdk/ml/azure-ai-ml",
        "/sdk/documentintelligence/azure-ai-documentintelligence",
        "/sdk/ai/azure-ai-inference",
        "/sdk/textanalytics/azure-ai-textanalytics",
        "/sdk/translation/azure-ai-translation-document",
        "/sdk/compute/azure-mgmt-compute",
        "/sdk/communication/azure-communication-chat",
        "/sdk/communication/azure-communication-identity",
        "/sdk/storage/azure-storage-blob"
    ],
    "azure-mgmt-core": [
        "/sdk/compute/azure-mgmt-compute",
        "/sdk/network/azure-mgmt-network",
        "/sdk/resources/azure-mgmt-resource",
        "/sdk/keyvault/azure-mgmt-keyvault"
    ]
}

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Get package version details from the repo")
    parser.add_argument("-s", "--search_path", required=True, help="The scope of the search")
    args = parser.parse_args()

    # Use abspath for the os.walk because if setup parsing fails it often changes cwd which throws off the relative walk
    for root, dirs, files in os.walk(os.path.abspath(args.search_path)):
        if re.search(r"sdk[\\/][^\\/]+[\\/][^\\/]+$", root):
            if "setup.py" in files:
                try:
                    parsed = ParsedSetup.from_path(root)

                    dependent_packages = ""
                    if parsed.name in additional_pr_triggers:
                        dependent_packages = ",".join(additional_pr_triggers[parsed.name])

                    print(
                        "{0} {1} {2} {3} {4}".format(
                            parsed.name,
                            parsed.version,
                            parsed.is_new_sdk,
                            os.path.dirname(parsed.setup_filename),
                            dependent_packages
                        )
                    )
                except:
                    # Skip setup.py if the package cannot be parsed
                    pass