File: __main__.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 (62 lines) | stat: -rw-r--r-- 1,808 bytes parent folder | download | duplicates (2)
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
import argparse
import logging
import os
import sys

from . import build_packaging

_LOGGER = logging.getLogger(__name__)

_epilog = """This script will automatically build the TOML configuration file with default value if it doesn't exist.
"""

parser = argparse.ArgumentParser(
    description="Packaging tools for Azure SDK for Python",
    formatter_class=argparse.RawTextHelpFormatter,
    epilog=_epilog,
)
parser.add_argument(
    "--output",
    "-o",
    dest="output",
    default=".",
    help="Output dir, should be SDK repo folder. [default: %(default)s]",
)
parser.add_argument("--debug", dest="debug", action="store_true", help="Verbosity in DEBUG mode")
parser.add_argument(
    "--build-conf",
    dest="build_conf",
    action="store_true",
    help="Build a default TOML file, with package name, fake pretty name, as beta package and no doc page. Do nothing if the file exists, remove manually the file if needed.",
)
parser.add_argument(
    "--jenkins",
    dest="jenkins",
    action="store_true",
    help="In Jenkins mode, try to find what to generate from Jenkins env variables. Package names are then optional.",
)
parser.add_argument("package_names", nargs="*", help="The package name.")

args = parser.parse_args()

main_logger = logging.getLogger()
logging.basicConfig()
main_logger.setLevel(logging.DEBUG if args.debug else logging.INFO)

if not args.package_names and not args.jenkins:
    raise ValueError("At least one package name or Jenkins mode is required")

try:
    build_packaging(
        args.output,
        os.environ.get("GH_TOKEN", None),
        args.jenkins,
        args.package_names,
        build_conf=args.build_conf,
    )
except Exception as err:
    if args.debug:
        _LOGGER.exception(err)
    else:
        _LOGGER.critical(err)
    sys.exit(1)