def main()

in ptr.py [0:0]


def main() -> None:
    default_stats_file = Path(gettempdir()) / f"ptr_stats_{getpid()}"
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "-a",
        "--atonce",
        default=int(CONFIG["ptr"]["atonce"]),
        type=int,
        help=f"How many tests to run at once [Default: {int(CONFIG['ptr']['atonce'])}]",
    )
    parser.add_argument(
        "-b",
        "--base-dir",
        default=CWD,
        help=f"Path to recursively look for setup.py files [Default: {CWD}]",
    )
    parser.add_argument(
        "-d", "--debug", action="store_true", help="Verbose debug output"
    )
    parser.add_argument(
        "-e",
        "--error-on-warnings",
        action="store_true",
        help="Have Python warnings raise DeprecationWarning on tests run",
    )
    parser.add_argument(
        "-k", "--keep-venv", action="store_true", help="Do not remove created venv"
    )
    parser.add_argument(
        "-m",
        "--mirror",
        default=CONFIG["ptr"]["pypi_url"],
        help=(
            f"URL for pip to use for Simple API [Default: {CONFIG['ptr']['pypi_url']}]"
        ),
    )
    parser.add_argument(
        "--print-cov", action="store_true", help="Print modules coverage report"
    )
    parser.add_argument(
        "--print-non-configured",
        action="store_true",
        help="Print modules not configured to run ptr",
    )
    parser.add_argument(
        "--progress-interval",
        default=0,
        type=float,
        help="Seconds between status update on test running [Default: Disabled]",
    )
    parser.add_argument(
        "--run-disabled",
        action="store_true",
        help="Force any disabled tests suites to run",
    )
    parser.add_argument(
        "--stats-file",
        default=str(default_stats_file),
        help=f"JSON statistics file [Default: {default_stats_file}]",
    )
    parser.add_argument(
        "--system-site-packages",
        action="store_true",
        help="Give the virtual environment access to the system site-packages dir",
    )
    parser.add_argument("--venv", help="Path to venv to reuse")
    parser.add_argument(
        "--venv-timeout",
        type=int,
        default=VENV_TIMEOUT,
        help=(
            "Timeout in seconds for venv creation + deps install [Default:"
            f" {VENV_TIMEOUT}]"
        ),
    )
    args = parser.parse_args()
    _handle_debug(args.debug)

    LOG.info(f"Starting {sys.argv[0]}")
    main_coro = async_main(
        args.atonce,
        _validate_base_dir(args.base_dir),
        args.mirror,
        args.progress_interval,
        args.venv,
        args.keep_venv,
        args.print_cov,
        args.print_non_configured,
        args.run_disabled,
        args.stats_file,
        args.venv_timeout,
        args.error_on_warnings,
        args.system_site_packages,
    )
    # This is gated to >= 3.8 for unittests
    # Once we're >= 3.7 tests could be refactored so we can use
    # asyncio.run in 3.7
    if getattr(asyncio, "run", None) and PY_38_OR_GREATER:
        sys.exit(asyncio.run(main_coro))
    else:
        loop = asyncio.get_event_loop()
        try:
            sys.exit(loop.run_until_complete(main_coro))
        finally:
            loop.close()