cli.py

python/src/entropic/cli.py

``entropic`` console script — dispatches to the bundled native binary.

Owners: @tvanfossen

_exec_native

int entropic.cli._exec_native(list[str] argv)

Replace this process with bin/entropic argv...; return on failure.

python/src/entropic/cli.py:36

Source · 15 lines
def _exec_native(argv: list[str]) -> int:
    """Replace this process with ``bin/entropic argv...``; return on failure."""
    bin_path = _loader.find_bin("entropic")
    if bin_path is None:
        print(
            "error: entropic native binary not found.\n"
            "       run `entropic install-engine` to fetch a release, "
            "or set $ENTROPIC_LIB to point at an in-tree build.",
            file=sys.stderr,
        )
        return 2
    os.execvp(str(bin_path), [str(bin_path), *argv])
    return 1  # unreachable; execvp does not return on success

Activity · 6 steps
lines 38–38bin_path = _loader.find_bin("entropic")lines 39–39◇ if bin_path is Nonelines 40–45print( "error: entropic native binary not found.\n" " run `entropic install-engine` to fetch a release, " "or set $ENTROPIC_LIB to point at an in-tree build.", file=sys.stderr, )lines 46–46return 2lines 47–47os.execvp(str(bin_path), [str(bin_path), *argv])lines 48–48return 1

Requirements

REQ-PROD-001

Flows

main

int entropic.cli.main(list[str]|None argv=None)

Console-script entry point.

python/src/entropic/cli.py:70

Source · 27 lines
def main(argv: list[str] | None = None) -> int:
    """Console-script entry point. argv excludes the program name."""
    args = list(sys.argv[1:] if argv is None else argv)
    if args and args[0] == "install-engine":
        if any(a in ("-h", "--help") for a in args[1:]):
            print(
                "Usage: entropic install-engine [--version V] [--backend cpu|cuda]\n"
                "\n"
                "  Fetch and verify the librentropic.so + entropic CLI tarball\n"
                "  for this wrapper version (or the version specified by\n"
                "  --version) from GitHub Releases, and extract under\n"
                "  ~/.entropic/ (override via $ENTROPIC_HOME).\n"
                "\n"
                "  --version V        Engine version to install (default: this\n"
                "                     wrapper's version).\n"
                "  --backend cpu|cuda Force a backend; default auto-detects\n"
                "                     CUDA via nvidia-smi."
            )
            return 0
        return install_engine.main(args[1:])
    if args and args[0] in ("-h", "--help"):
        # Surface the wrapper-only subcommand alongside the native binary's help.
        print(_INSTALL_ENGINE_HELP)
        sys.stdout.flush()
    return _exec_native(args)

Activity · 10 steps
lines 72–72args = list(sys.argv[1:] if argv is None else argv)lines 73–73◇ if args and args[0] == "install-engine"lines 74–74◇ if any(a in ("-h", "--help") for a in args[1:])lines 75–87print( "Usage: entropic install-engine [--version V] [--backend cpu|cuda]\n" "\n" " Fetch and verify the librentropic.so + entropic CLI tarball\n" " for this wrapper version (or the version specified by\n" " --version) from GitHub Releases, and extract under\n" " ~/.entropic/ (override via $ENTROPIC_HOME).\n" "\n" " --version V Engine version to install (default: this\n" " wrapper's version).\n" " --backend cpu|cuda Force a backend; default auto-detects\n" " CUDA via nvidia-smi." )lines 88–88return 0lines 89–89return install_engine.main(args[1:])lines 90–90◇ if args and args[0] in ("-h", "--help")lines 92–92print(_INSTALL_ENGINE_HELP)lines 93–93sys.stdout.flush()lines 94–94return _exec_native(args)

Requirements

REQ-PROD-001

Flows