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