Hi Andrea,

On 11.01.07, andrea valle wrote:
> I was trying to call python with a .py file containing pyx code from 
> inside SuperCollider language. It happens that the stdout from 
> SuperCollider works. I'm able to execute python code generating txt 
> files, just like I was using the shell. But there's a problem with PyX 
> code when I use .writePDFfile. While writing the pdf the process 
> evidently raise some errors.  
> In fact it does not return 0, but 256 (?). The resulting pdf is zero 
> kb.  
> And a temporary .tex file rest in the SuperCollider folder which is not 
> the place I chose to generate the pdf (while the pdf is in its right 
> place as defined by me in the path). I guess that the temporary .tex 
> should be in the same folder of the (definitive) pdf, shouldn't it? 
> 
> EG 
> 
> Input 
> - unixCmd("python /Users/apple/Desktop/testPyX.py"); (this is 
> SuperCollider) 
> 
> /Users/apple/Desktop/testPyX.py: contains this line --> 
> g.writePDFfile("/Users/apple/Desktop/testPyX.pdf") 
> (the file behave as expected if executed directly from terminal) 
> 
> Ouput: 
> - returns from terminal inside SC: 256 
> - /Users/apple/Desktop/testPyX.pdf: exists but is 0 kbyte 
> - tmp8W3ZN1.tex: is in the SuperCollider folder under Applications 
> (containg a nice advise: %relax...)  
> 
> Any hints? 

I'm not sure whether you're still interested in that very old question
(I'm going randomly thru my PyX mailbox where I putted all kind of
stuff I didn't had time to answer). But there are some really deep
thoughts in why PyX uses TeX like it does. Let me enlight you a
little:

First of all, right, PyX writes a TeX file containing "relax" in only.
Always when it runs TeX. TeX is then used on the by stdin/stdout
channels to avoid certain buffering issues which would occur when we
would use a file (i.e. named pipe) driven TeX-handling. By that we can
fetch TeX errors right when they happen and we get the size of the
output as well (without needing to rely on TeX hacks like the --ipc
option of TeX, which is not available on all TeX installations). But
we need to start running TeX using a file (and thus we have this file
containing \relax only), since that is the only way to set TeXs
\jobname, which defines the name of the output file.

Ok, now to the questions where the temporary TeX file is stored. We
decided to use the current directory, which sounds a bit stange. But
there are good reasons for that. When you do

    echo 'hello, world!\bye' > /tmp/test.tex; tex /tmp/test.tex

the test.log and test.dvi would still be created in the current
directory! (\jobname does not contain the directory.) You may consider
that a bug, but it's the way TeX works. Now, as the dvifile and the
logfile are both created in the current directory anyway, we also put
the TeX file there. It doesn't matter anyway.

I should emphasize, that we considered changing the directory to say
/tmp before/while running TeX not an option at all, since people might
want to put some style files in the current directory and would wonder
completely why they would not get used by PyX. We don't have any
control on what people are doing inside TeX ... PyX does not even try
to understand what you're doing with TeX (and IMHO that's the only
right choice).

Still, you could just do a os.chdir in the beginning of your script
and thus do everything in that directory. That's totally fine with me.
But it's unlikely that we'll change PyXs behaviour, since it was
derived to be the best solution (known) after we did spend quite some
time trying different solutions.


André

-- 
by  _ _      _    Dr. André Wobst
   / \ \    / )   [EMAIL PROTECTED], http://www.wobsta.de/
  / _ \ \/\/ /    PyX - High quality PostScript and PDF figures
 (_/ \_)_/\_/     with Python & TeX: visit http://pyx.sourceforge.net/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user

Reply via email to