Updated 10/23: put [BUG] in title, clarified a few issues about the test script.
I am having a weird issue with subprocess.Popen as invoked from my LaTeXTools plugin. A user reported the following bug: a LaTeX file containing a picture originally in eps format fails to compile when building from ST2, but builds just fine when invoking the exact same command that the plugin uses from the command line.
What’s special (sort of) about this file is that the LaTeX graphics package, upon encountering the eps file, is smart enough to invoke the epstopdf command from within tex, and then import the resulting pdf file. This is what fails under ST2.
I can confirm that running the appropriate latex build command from the command line works just fine. In fact, I wrote a python script that invokes the exact same command used by the LaTeXTools plugin, using subprocess.Popen—again, this is copied line by line from the plugin. The results: if I run the script from the command line, everything works. If I run the script from within the ST2 console, I have exactly the same behavior that I observe when I build from ST2. I reproduce the script below for convenience.
What is going on? Is there some limitation on processes run from ST2 that in turn spawn other processes? Note that TeXshop has no trouble at all with eps file conversion on the fly.
Here’s the script. Again, this is not the plugin code: just a standalone test script. The actual plugin code gets the file name from the current view, etc. Also note that the path is set so tex and friends (including epstopdf) are reachable. Also, I tested this on OS X; I haven’t tried it on Windows. The problem exists up to the current release, 2134.
import sys, os, os.path
import subprocess
make_cmd = "latexmk",
"-e", "$pdflatex = q/pdflatex %O -synctex=1 %S/",
"-f", "-pdf"]
file_name = os.path.normpath("/Users/xxxxx/Documents/temp/sublimeTests/epstest/epstest.tex")
tex_dir = os.path.dirname(file_name)
cmd = make_cmd + [file_name]
print cmd
path = "$PATH:/usr/texbin"
old_path = os.environ"PATH"]
os.environ"PATH"] = os.path.expandvars(path).encode(sys.getfilesystemencoding())
os.chdir(tex_dir)
proc = subprocess.Popen(cmd)
proc.wait()
os.environ"PATH"] = old_path
print proc.returncode