Comment 5 for bug 1045284

Revision history for this message
vovkkk (vovkkk) wrote :

> I used the module apt only to detect if someone already has some sort of texlive installed

How about this:

<...>

    latex_engine = ''
    if export_type == "pdf":
        args.append("-o%s.pdf" % basename)
        args.append("--latex-engine=%s" % self.latex_engine)

<...>

def export_as_pdf(self, widget, data=None):
    if self.texlive_installed == False:
        args = [('pdflatex', '-version'), ('xelatex', '-version'), ('lualatex', '-version')]
        for c, o in args:
            inst = True
            try:
                args = (c, o)
                subprocess.Popen(args)
                self.latex_engine = c
                break
            except OSError:
                inst = False

The idea is pretty simple: we just call possible converters (tex to pdf) and if Popen fails it raises OSError which means no such file, i.e. Texlive is not installed or is not in PATH
By default Pandoc uses pdflatex, so it can be actually simplier — without loop, but probably for custom installations (from sources) it might be useful, I'm not sure though.

Note that '-version' option is used just to avoid interactive mode which provided by those tools

I cannot try this on other dists, pity, but on Ubuntu 12.04 with UW from trunk it seems work.