def main()

in scripts/setup.py [0:0]


def main() -> None:
    logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s")

    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--name", type=str, default="mariana-trench", help="Package name."
    )
    parser.add_argument(
        "--version", type=str, default="0.dev0", help="Package version."
    )
    parser.add_argument(
        "--repository",
        type=_directory_exists,
        default=".",
        help="Path to the root of the repository.",
    )
    parser.add_argument(
        "--binary",
        type=_executable_exists,
        help="Path to the analyzer binary.",
        required=True,
    )
    parser.add_argument(
        "--pyredex",
        type=_python_directory_exists,
        help="Path to the pyredex directory.",
        required=True,
    )
    subparsers = parser.add_subparsers(dest="command")
    subparsers.add_parser("build", help="Build the pypi package")
    subparsers.add_parser("install", help="Install the pypi package")
    arguments: argparse.Namespace = parser.parse_args()

    repository: Path = arguments.repository
    if (
        not (repository / "README.md").exists()
        and (repository / "../README.md").exists()
    ):
        repository = repository / ".."

    _install_build_dependencies()
    with tempfile.TemporaryDirectory() as build_root:
        build_path = Path(build_root)
        _prepare_build_directory(
            build_path,
            arguments.name,
            arguments.version,
            repository,
            arguments.binary,
            arguments.pyredex,
        )

        if arguments.command == "build":
            _build_package(build_path)
            _copy_package(build_path, Path(os.getcwd()))
        elif arguments.command == "install":
            _install_package(build_path)