File: get_package_properties.py

package info (click to toggle)
python-azure 20230112%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 749,544 kB
  • sloc: python: 6,815,827; javascript: 287; makefile: 195; xml: 109; sh: 105
file content (27 lines) | stat: -rw-r--r-- 1,075 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
import argparse
import sys
import glob
import os
import re

from ci_tools.parsing import ParsedSetup

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)
                    print(
                        "{0} {1} {2} {3}".format(
                            parsed.name, parsed.version, parsed.is_new_sdk, os.path.dirname(parsed.setup_filename)
                        )
                    )
                except:
                    # Skip setup.py if the package cannot be parsed
                    pass