foley.external#
Running a tool as an external program: find it, run it, report its failure.
Some backends cannot share foley’s process or environment: MFA installs with conda,
aeneas is AGPL, fadtk and kadtk pin numpy<2. foley runs each as a subprocess (often an
interpreter in its own virtualenv) that writes its result to a file. This module is
the shared part: resolving the executable with an install hint, and running the
command with an injectable runner so that a non-zero exit or a missing output file
raises with the tail of the program’s output; and giving a conda program its env’s
bin on PATH. Stdlib only.
Module Attributes
Runs a command ( |
|
How much of a failed program's output an error quotes (its tail, in characters). |
Functions
|
|
|
Run |
|
This process's environment with |
- foley.external.ERROR_TAIL_CHARS = 800#
How much of a failed program’s output an error quotes (its tail, in characters).
- foley.external.Runner#
Runs a command (
subprocess.run’s signature); injected in tests.alias of
Callable[[…],subprocess.CompletedProcess]
- foley.external.resolve_program(program, *, what, install)[source]#
programas an executable path, or aFileNotFoundErrorsaying how to get it.- Return type:
- foley.external.run_program(command, *, out, runner=<function run>, env=None, timeout=None, cwd=None, what='external program')[source]#
Run
command, which must writeout; return that file’s text.- Raises:
RuntimeError – If the program exits non-zero or writes no
out(the tail of its stderr, else stdout, is in the message).TimeoutExpired – If it runs past
timeoutseconds.
- Return type:
- foley.external.with_program_dir_on_path(program)[source]#
This process’s environment with
program’s directory first onPATH.A conda-installed program (MFA) calls helper binaries (
fstcompile) from its ownbin, which is onPATHonly while that env is activated; this makes a path to the executable (or a symlink to it) enough. POSIX layout: on Windows a conda env keeps its helpers inLibrary\bin, so activate the env there.