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
|
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)
|