Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I wrote a Python script to automate some LaTeX builds. Currently I develop/test on Mac OS X (did not try it on other UNIX flavors).

The particular execution function which should compile the LaTeX into a pdf document looks like:

def execute(texinputs, params, proj_dir):
    latex_cmd = '/usr/texbin/xelatex'

    params=shlex.split(params)
    if params is None or len(params)==0:
        params = [latex_cmd]
    else:
        params.insert(0, latex_cmd)

    environment = os.environ
    oldenv = environment.get('TEXINPUTS', '')
    prepand = ':'.join([input for input in texinputs])
    environment['TEXINPUTS']=prepand+':'+oldenv
    ptoken=subprocess.Popen(params, env=environment, cwd=proj_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    with ptoken.stdout as stdout:
        with ptoken.stderr as stderr:
            for _i in range(1,10):
                if ptoken.poll() is None:
                    time.sleep(1)
            ret=ptoken.returncode 
            if ptoken.returncode is None:
                ret = -1000
                ptoken.kill()
            outlines, errlines = stdout.readlines(), stderr.readlines()
            return ret, outlines, errlines 

What I do here is passing the paths to some generated sources which should be pre-pended to TEXINPUTS to resolve relative paths inside my LaTeX template as well as some additional tex processor parameters.

A typical shell command call (which works fine) is:

TEXINPUTS=/Users/ovanes/Documents/some_path/content:$TEXINPUTS /usr/texbin/xelatex -shell-escape main.tex

This produces a main.pdf which is fine. However, running this shell command from the script I see the following output and no main.pdf is written.

Error 32512 (driver return code) generating output;
file main.pdf may not be valid.

Any ideas?

share|improve this question
    
TeX related questions should be asked at TeX.SX (tex.stackexchange.com). The meta.tex.stackexchange.com site you posted it is for discussions, bug reports etc. about TeX.SX. I migrated it to the right place. –  Martin Scharrer Jun 27 '11 at 10:46
    
check this, maybe it suits your needs. bitbucket.org/ms4py/latexmk.py/wiki/Home –  pmav99 Jun 27 '11 at 11:00
    
Thanks for help, but not really. My builder can generate dynamic content which can be embedded into the existing LaTeX template. Smth. like writing a letter to all your customers requires you to generate for each customer personalized letter. This python script, can update the address field and recompile the document. It is not like conventional build systems. –  ovanes Jun 29 '11 at 19:33
add comment

migrated from meta.tex.stackexchange.com Jun 27 '11 at 10:44

This question came from our discussion, support, and feature requests site for users of TeX, LaTeX, ConTeXt, and related typesetting systems.

1 Answer

up vote 4 down vote accepted

Ok, I found out the problem. I overlooked that LaTeX processer could not start xdvipdfmx due to path problems. Finally, appending '/usr/texbin' to the PATH environment of the child process worked fine.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.