kpathsea 0.3.4

Rust interface to the kpathsea TeX file management library.
Documentation

High-level Rust API for working with the kpathsea file-searching library for TeX

Two backends are provided:

  • in-process — FFI calls into the system libkpathsea (the fast path, microseconds per lookup). Selected automatically when the library was found at build time: pkg-config or the KPATHSEA_LIB_DIR override on Unix, TeX Live's own kpathsea DLL (found next to kpsewhich.exe) on Windows — see kpathsea_sys's build script. KPATHSEA_NO_LINK=1 at build time forces the subprocess backend even when a library is available.
  • subprocess — delegates to the host TeX distribution's own kpsewhich executable, fronted by a one-shot cache of the TeX tree's ls-R databases. Selected automatically when libkpathsea was not found at build time (e.g. MacTeX/BasicTeX ship no library at all), or explicitly via [Kpaths::new_subprocess]. Because it asks the host's resolver binary, it stays in sync with the ambient distribution by construction — including MiKTeX, which reimplements kpathsea. (This mirrors how Perl LaTeXML has always resolved TeX files; see src/subprocess.rs.)

Latency profile (measured on a full TeX Live): in-process lookups are tens of µs, hit or miss. Subprocess lookups are bimodal: sub-µs on an ls-R cache hit — faster than the FFI path — but a cache miss costs a kpsewhich spawn (tens to hundreds of ms, memoized process-wide per executable so a repeated miss is only ever paid once, regardless of which instance or thread asks).