tex¶
TeX/LaTeX/PDFLaTeX/XeLaTeX support
Example:
def configure(conf):
conf.load('tex')
if not conf.env.LATEX:
conf.fatal('The program LaTex is required')
def build(bld):
bld(
features = 'tex',
type = 'latex', # pdflatex or xelatex
source = 'document.ltx', # mandatory, the source
outs = 'ps', # 'pdf' or 'ps pdf'
deps = 'crossreferencing.lst', # to give dependencies directly
prompt = 1, # 0 for the batch mode
)
Notes:
To configure with a special program, use:
$ PDFLATEX=luatex waf configure
This tool does not use the target attribute of the task generator (
bld(target=...)
); the target file name is built from the source base name and the output type(s)
- waflib.Tools.tex.feature(*k)¶
Decorator that registers a task generator method that will be executed when the object attribute
feature
contains the corresponding key(s):from waflib.TaskGen import feature @feature('myfeature') def myfunction(self): print('that is my feature!') def build(bld): bld(features='myfeature')
- Parameters
k (list of string) – feature names
- waflib.Tools.tex.before_method(*k)[source]¶
Decorator that registera task generator method which will be executed before the functions of given name(s):
from waflib.TaskGen import feature, before @feature('myfeature') @before_method('fun2') def fun1(self): print('feature 1!') @feature('myfeature') def fun2(self): print('feature 2!') def build(bld): bld(features='myfeature')
- Parameters
k (list of string) – method names
- waflib.Tools.tex.bibunitscan(self)[source]¶
Parses TeX inputs and try to find the bibunit file dependencies
- Returns
list of bibunit files
- Return type
list of
waflib.Node.Node
- waflib.Tools.tex.known_tex_env_vars = ['TEXINPUTS', 'TEXFONTS', 'PKFONTS', 'TEXPKS', 'GFFONTS']¶
Tex environment variables that are should cause rebuilds when the values change
- waflib.Tools.tex.exts_deps_tex = ['', '.ltx', '.tex', '.bib', '.pdf', '.png', '.eps', '.ps', '.sty']¶
List of typical file extensions included in latex files
- waflib.Tools.tex.exts_tex = ['.ltx', '.tex']¶
List of typical file extensions that contain latex
- waflib.Tools.tex.re_tex = re.compile('\\\\(?P<type>usepackage|RequirePackage|include|bibliography([^\\[\\]{}]*)|putbib|includegraphics|input|import|bringin|lstinputlisting)(\\[[^\\[\\]]*\\])?{(?P<file>[^{}]*)}', re.MULTILINE)¶
Regexp for expressions that may include latex files
- waflib.Tools.tex.g_bibtex_re = re.compile('bibdata', re.MULTILINE)¶
Regexp for bibtex files
- waflib.Tools.tex.g_glossaries_re = re.compile('\\@newglossary', re.MULTILINE)¶
Regexp for expressions that create glossaries
- class waflib.Tools.tex.tex(*k, **kw)[source]¶
Compiles a tex/latex file.
A series of applications need to be run by setting certain environmental variables; these variables are repeatedly regenerated during processing (self.env.env).
- bibtex_fun()¶
Execute the program bibtex
- makeindex_fun()¶
Execute the program makeindex
- makeglossaries_fun()¶
Execute the program makeglossaries
- _ = ['MAKEGLOSSARIES', 'SRCFILE']¶
- exec_command(cmd, **kw)[source]¶
Executes TeX commands without buffering (latex may prompt for inputs)
- Returns
the return code
- Return type
int
- scan()[source]¶
Recursive regex-based scanner that finds latex dependencies. It uses
waflib.Tools.tex.re_tex
Depending on your needs you might want:
to change re_tex:
from waflib.Tools import tex tex.re_tex = myregex
or to change the method scan from the latex tasks:
from waflib.Task import classes classes['latex'].scan = myscanfunction
- check_status(msg, retcode)[source]¶
Checks an exit status and raise an error with a particular message
- Parameters
msg (string) – message to display if the code is non-zero
retcode (boolean) – condition
- bibfile()[source]¶
Parses .aux files to find bibfiles to process. If present, execute
waflib.Tools.tex.tex.bibtex_fun()
- bibunits()[source]¶
Parses .aux file to find bibunit files. If there are bibunit files, runs
waflib.Tools.tex.tex.bibtex_fun()
.
- makeindex()[source]¶
Searches the filesystem for .idx files to process. If present, runs
waflib.Tools.tex.tex.makeindex_fun()
- makeglossaries()[source]¶
Lists additional glossaries from .aux files. If present, runs the makeglossaries program.
- texinputs()[source]¶
Returns the list of texinput nodes as a string suitable for the TEXINPUTS environment variables
- Return type
string
- run()[source]¶
Runs the whole TeX build process
Multiple passes are required depending on the usage of cross-references, bibliographies, glossaries, indexes and additional contents The appropriate TeX compiler is called until the .aux files stop changing.
- hasrun¶
- generator¶
- env¶
waflib.ConfigSet.ConfigSet
object (make sure to provide one)
- inputs¶
List of input nodes, which represent the files used by the task instance
- outputs¶
List of output nodes, which represent the files created by the task instance
- dep_nodes¶
List of additional nodes to depend on
- run_after¶
Set of tasks that must be executed before this one
- hcode = b'\tdef run(self):\n\t\t"""\n\t\tRuns the whole TeX build process\n\n\t\tMultiple passes are required depending on the usage of cross-references,\n\t\tbibliographies, glossaries, indexes and additional contents\n\t\tThe appropriate TeX compiler is called until the *.aux* files stop changing.\n\t\t"""\n\t\tenv = self.env\n\n\t\tif not env.PROMPT_LATEX:\n\t\t\tenv.append_value(\'LATEXFLAGS\', \'-interaction=nonstopmode\')\n\t\t\tenv.append_value(\'PDFLATEXFLAGS\', \'-interaction=nonstopmode\')\n\t\t\tenv.append_value(\'XELATEXFLAGS\', \'-interaction=nonstopmode\')\n\n\t\t# important, set the cwd for everybody\n\t\tself.cwd = self.inputs[0].parent.get_bld()\n\n\t\tself.info(\'first pass on %s\', self.__class__.__name__)\n\n\t\t# Hash .aux files before even calling the LaTeX compiler\n\t\tcur_hash = self.hash_aux_nodes()\n\n\t\tself.call_latex()\n\n\t\t# Find the .aux files again since bibtex processing can require it\n\t\tself.hash_aux_nodes()\n\n\t\tself.bibtopic()\n\t\tself.bibfile()\n\t\tself.bibunits()\n\t\tself.makeindex()\n\t\tself.makeglossaries()\n\n\t\tfor i in range(10):\n\t\t\t# There is no need to call latex again if the .aux hash value has not changed\n\t\t\tprev_hash = cur_hash\n\t\t\tcur_hash = self.hash_aux_nodes()\n\t\t\tif not cur_hash:\n\t\t\t\tLogs.error(\'No aux.h to process\')\n\t\t\tif cur_hash and cur_hash == prev_hash:\n\t\t\t\tbreak\n\n\t\t\t# run the command\n\t\t\tself.info(\'calling %s\', self.__class__.__name__)\n\t\t\tself.call_latex()\n'¶
String representing an additional hash for the class representation
- class waflib.Tools.tex.latex(*k, **kw)[source]¶
Compiles LaTeX files
- vars = ['LATEX', 'LATEXFLAGS', 'SRCFILE', 'TEXDEPS']¶
ConfigSet variables that should trigger a rebuild (class attribute used for
waflib.Task.Task.sig_vars()
)
- hasrun¶
- generator¶
- env¶
waflib.ConfigSet.ConfigSet
object (make sure to provide one)
- inputs¶
List of input nodes, which represent the files used by the task instance
- outputs¶
List of output nodes, which represent the files created by the task instance
- dep_nodes¶
List of additional nodes to depend on
- run_after¶
Set of tasks that must be executed before this one
- hcode = b'\tdef run(self):\n\t\t"""\n\t\tRuns the whole TeX build process\n\n\t\tMultiple passes are required depending on the usage of cross-references,\n\t\tbibliographies, glossaries, indexes and additional contents\n\t\tThe appropriate TeX compiler is called until the *.aux* files stop changing.\n\t\t"""\n\t\tenv = self.env\n\n\t\tif not env.PROMPT_LATEX:\n\t\t\tenv.append_value(\'LATEXFLAGS\', \'-interaction=nonstopmode\')\n\t\t\tenv.append_value(\'PDFLATEXFLAGS\', \'-interaction=nonstopmode\')\n\t\t\tenv.append_value(\'XELATEXFLAGS\', \'-interaction=nonstopmode\')\n\n\t\t# important, set the cwd for everybody\n\t\tself.cwd = self.inputs[0].parent.get_bld()\n\n\t\tself.info(\'first pass on %s\', self.__class__.__name__)\n\n\t\t# Hash .aux files before even calling the LaTeX compiler\n\t\tcur_hash = self.hash_aux_nodes()\n\n\t\tself.call_latex()\n\n\t\t# Find the .aux files again since bibtex processing can require it\n\t\tself.hash_aux_nodes()\n\n\t\tself.bibtopic()\n\t\tself.bibfile()\n\t\tself.bibunits()\n\t\tself.makeindex()\n\t\tself.makeglossaries()\n\n\t\tfor i in range(10):\n\t\t\t# There is no need to call latex again if the .aux hash value has not changed\n\t\t\tprev_hash = cur_hash\n\t\t\tcur_hash = self.hash_aux_nodes()\n\t\t\tif not cur_hash:\n\t\t\t\tLogs.error(\'No aux.h to process\')\n\t\t\tif cur_hash and cur_hash == prev_hash:\n\t\t\t\tbreak\n\n\t\t\t# run the command\n\t\t\tself.info(\'calling %s\', self.__class__.__name__)\n\t\t\tself.call_latex()\n'¶
String representing an additional hash for the class representation
- class waflib.Tools.tex.pdflatex(*k, **kw)[source]¶
Compiles PdfLaTeX files
- vars = ['PDFLATEX', 'PDFLATEXFLAGS', 'SRCFILE', 'TEXDEPS']¶
ConfigSet variables that should trigger a rebuild (class attribute used for
waflib.Task.Task.sig_vars()
)
- hasrun¶
- generator¶
- env¶
waflib.ConfigSet.ConfigSet
object (make sure to provide one)
- inputs¶
List of input nodes, which represent the files used by the task instance
- outputs¶
List of output nodes, which represent the files created by the task instance
- dep_nodes¶
List of additional nodes to depend on
- run_after¶
Set of tasks that must be executed before this one
- hcode = b'\tdef run(self):\n\t\t"""\n\t\tRuns the whole TeX build process\n\n\t\tMultiple passes are required depending on the usage of cross-references,\n\t\tbibliographies, glossaries, indexes and additional contents\n\t\tThe appropriate TeX compiler is called until the *.aux* files stop changing.\n\t\t"""\n\t\tenv = self.env\n\n\t\tif not env.PROMPT_LATEX:\n\t\t\tenv.append_value(\'LATEXFLAGS\', \'-interaction=nonstopmode\')\n\t\t\tenv.append_value(\'PDFLATEXFLAGS\', \'-interaction=nonstopmode\')\n\t\t\tenv.append_value(\'XELATEXFLAGS\', \'-interaction=nonstopmode\')\n\n\t\t# important, set the cwd for everybody\n\t\tself.cwd = self.inputs[0].parent.get_bld()\n\n\t\tself.info(\'first pass on %s\', self.__class__.__name__)\n\n\t\t# Hash .aux files before even calling the LaTeX compiler\n\t\tcur_hash = self.hash_aux_nodes()\n\n\t\tself.call_latex()\n\n\t\t# Find the .aux files again since bibtex processing can require it\n\t\tself.hash_aux_nodes()\n\n\t\tself.bibtopic()\n\t\tself.bibfile()\n\t\tself.bibunits()\n\t\tself.makeindex()\n\t\tself.makeglossaries()\n\n\t\tfor i in range(10):\n\t\t\t# There is no need to call latex again if the .aux hash value has not changed\n\t\t\tprev_hash = cur_hash\n\t\t\tcur_hash = self.hash_aux_nodes()\n\t\t\tif not cur_hash:\n\t\t\t\tLogs.error(\'No aux.h to process\')\n\t\t\tif cur_hash and cur_hash == prev_hash:\n\t\t\t\tbreak\n\n\t\t\t# run the command\n\t\t\tself.info(\'calling %s\', self.__class__.__name__)\n\t\t\tself.call_latex()\n'¶
String representing an additional hash for the class representation
- class waflib.Tools.tex.xelatex(*k, **kw)[source]¶
XeLaTeX files
- vars = ['XELATEX', 'XELATEXFLAGS', 'SRCFILE', 'TEXDEPS']¶
ConfigSet variables that should trigger a rebuild (class attribute used for
waflib.Task.Task.sig_vars()
)
- hasrun¶
- generator¶
- env¶
waflib.ConfigSet.ConfigSet
object (make sure to provide one)
- inputs¶
List of input nodes, which represent the files used by the task instance
- outputs¶
List of output nodes, which represent the files created by the task instance
- dep_nodes¶
List of additional nodes to depend on
- run_after¶
Set of tasks that must be executed before this one
- hcode = b'\tdef run(self):\n\t\t"""\n\t\tRuns the whole TeX build process\n\n\t\tMultiple passes are required depending on the usage of cross-references,\n\t\tbibliographies, glossaries, indexes and additional contents\n\t\tThe appropriate TeX compiler is called until the *.aux* files stop changing.\n\t\t"""\n\t\tenv = self.env\n\n\t\tif not env.PROMPT_LATEX:\n\t\t\tenv.append_value(\'LATEXFLAGS\', \'-interaction=nonstopmode\')\n\t\t\tenv.append_value(\'PDFLATEXFLAGS\', \'-interaction=nonstopmode\')\n\t\t\tenv.append_value(\'XELATEXFLAGS\', \'-interaction=nonstopmode\')\n\n\t\t# important, set the cwd for everybody\n\t\tself.cwd = self.inputs[0].parent.get_bld()\n\n\t\tself.info(\'first pass on %s\', self.__class__.__name__)\n\n\t\t# Hash .aux files before even calling the LaTeX compiler\n\t\tcur_hash = self.hash_aux_nodes()\n\n\t\tself.call_latex()\n\n\t\t# Find the .aux files again since bibtex processing can require it\n\t\tself.hash_aux_nodes()\n\n\t\tself.bibtopic()\n\t\tself.bibfile()\n\t\tself.bibunits()\n\t\tself.makeindex()\n\t\tself.makeglossaries()\n\n\t\tfor i in range(10):\n\t\t\t# There is no need to call latex again if the .aux hash value has not changed\n\t\t\tprev_hash = cur_hash\n\t\t\tcur_hash = self.hash_aux_nodes()\n\t\t\tif not cur_hash:\n\t\t\t\tLogs.error(\'No aux.h to process\')\n\t\t\tif cur_hash and cur_hash == prev_hash:\n\t\t\t\tbreak\n\n\t\t\t# run the command\n\t\t\tself.info(\'calling %s\', self.__class__.__name__)\n\t\t\tself.call_latex()\n'¶
String representing an additional hash for the class representation
- class waflib.Tools.tex.dvips(*k, **kw)[source]¶
Converts dvi files to postscript
- color = 'BLUE'¶
Color for the console display, see
waflib.Logs.colors_lst
- after = ['latex', 'pdflatex', 'xelatex']¶
The instances of this class are executed after the instances of classes whose names are in this list
- hasrun¶
- generator¶
- env¶
waflib.ConfigSet.ConfigSet
object (make sure to provide one)
- inputs¶
List of input nodes, which represent the files used by the task instance
- outputs¶
List of output nodes, which represent the files created by the task instance
- dep_nodes¶
List of additional nodes to depend on
- run_after¶
Set of tasks that must be executed before this one
- hcode = b'${DVIPS} ${DVIPSFLAGS} ${SRC} -o ${TGT}'¶
String representing an additional hash for the class representation
- orig_run_str = '${DVIPS} ${DVIPSFLAGS} ${SRC} -o ${TGT}'¶
- vars = ['DVIPS', 'DVIPSFLAGS']¶
ConfigSet variables that should trigger a rebuild (class attribute used for
waflib.Task.Task.sig_vars()
)
- class waflib.Tools.tex.dvipdf(*k, **kw)[source]¶
Converts dvi files to pdf
- hasrun¶
- generator¶
- env¶
waflib.ConfigSet.ConfigSet
object (make sure to provide one)
- inputs¶
List of input nodes, which represent the files used by the task instance
- outputs¶
List of output nodes, which represent the files created by the task instance
- dep_nodes¶
List of additional nodes to depend on
- run_after¶
Set of tasks that must be executed before this one
- color = 'BLUE'¶
Color for the console display, see
waflib.Logs.colors_lst
- hcode = b'${DVIPDF} ${DVIPDFFLAGS} ${SRC} ${TGT}'¶
String representing an additional hash for the class representation
- orig_run_str = '${DVIPDF} ${DVIPDFFLAGS} ${SRC} ${TGT}'¶
- vars = ['DVIPDF', 'DVIPDFFLAGS']¶
ConfigSet variables that should trigger a rebuild (class attribute used for
waflib.Task.Task.sig_vars()
)
- after = ['latex', 'pdflatex', 'xelatex']¶
The instances of this class are executed after the instances of classes whose names are in this list
- class waflib.Tools.tex.pdf2ps(*k, **kw)[source]¶
Converts pdf files to postscript
- hasrun¶
- generator¶
- env¶
waflib.ConfigSet.ConfigSet
object (make sure to provide one)
- inputs¶
List of input nodes, which represent the files used by the task instance
- outputs¶
List of output nodes, which represent the files created by the task instance
- dep_nodes¶
List of additional nodes to depend on
- run_after¶
Set of tasks that must be executed before this one
- hcode = b'${PDF2PS} ${PDF2PSFLAGS} ${SRC} ${TGT}'¶
String representing an additional hash for the class representation
- orig_run_str = '${PDF2PS} ${PDF2PSFLAGS} ${SRC} ${TGT}'¶
- vars = ['PDF2PS', 'PDF2PSFLAGS']¶
ConfigSet variables that should trigger a rebuild (class attribute used for
waflib.Task.Task.sig_vars()
)
- color = 'BLUE'¶
Color for the console display, see
waflib.Logs.colors_lst
- after = ['latex', 'pdflatex', 'xelatex']¶
The instances of this class are executed after the instances of classes whose names are in this list
- waflib.Tools.tex.apply_tex(self)[source]¶
Task generator method
Creates
waflib.Tools.tex.tex
objects, and dvips/dvipdf/pdf2ps tasks if necessary (outs=’ps’, etc).- Feature
- waflib.Tools.tex.configure(self)[source]¶
Find the programs tex, latex and others without raising errors.
Features defined in this module: