GLE compiler

class gleplot.GLECompiler(gle_path=None)[source]

Wrapper for GLE command-line compiler.

When gle_path is not given explicitly, the GLE executable is located via find_gle(), which searches (in order) the GLE_PATH environment variable, PATH (via shutil.which()), and a set of platform-specific well-known install locations. Set GLE_PATH to pin a specific GLE binary, e.g. when multiple versions are installed.

Parameters:

gle_path (str | None)

compile(input_file, output_format='pdf', dpi=150, verbose=False, timeout=30, cairo=False, transparent=False, grayscale=False)[source]

Compile GLE file to output format.

Parameters:
  • input_file (str) – Path to .gle input file

  • output_format ({'pdf', 'png', 'eps', 'jpg', 'svg'}) – Output format

  • dpi (int) – DPI for raster formats (png, jpg)

  • verbose (bool) – Log GLE’s output (stdout and stderr) to the gleplot.compiler logger at INFO level. Nothing reaches the console unless logging is configured, e.g. logging.basicConfig(level="INFO"). On failure the output is in the raised GLECompileError whether or not this is set.

  • timeout (int) – Maximum number of seconds to allow the GLE process to run.

  • cairo (bool) – Whether to pass GLE’s -cairo device flag (SPEC §6.1/§10.6). Required for any script using semi-transparency (an rgba(...)/rgba255(...) colour – e.g. a fill_between with alpha < 1); without it GLE fails outright on such a script (semi-transparency only supported with command line option '-cairo'). This method has no Figure to inspect, so it never decides this for you – cairo is an explicit, caller-supplied override. gleplot.figure.Figure.savefig() is the caller that does have the figure and passes figure.requires_cairo() here automatically; pass an explicit True/False yourself when compiling a .gle file this compiler didn’t write (or to force the flag either way). An svg always gets the flag (see build_compile_args()).

  • transparent (bool) – Give a PNG an alpha channel instead of a white background (GLE’s -transparent); see build_compile_args() for the other formats and for a grayscale PNG.

  • grayscale (bool) – Convert the colours GLE draws to their grey level (GLE’s -nocolor); see build_compile_args() for colormap images.

Returns:

Path to output file

Return type:

Path

Raises:
  • FileNotFoundError – If the input file does not exist.

  • GLECompileError – If compilation fails (nonzero exit code, or the expected output file was not produced). Carries structured errors and the raw_output from the GLE process. When the failure is an include file GLE cannot find, the message names the file and points to installing GLE’s include library.

info()[source]

Get GLE version and info.

Return type:

dict