Skip to content

unix installer (tested on macport install of latex) - #4

Closed
obtitus wants to merge 14 commits into
gpoore:masterfrom
obtitus:master
Closed

unix installer (tested on macport install of latex)#4
obtitus wants to merge 14 commits into
gpoore:masterfrom
obtitus:master

Conversation

@obtitus

@obtitus obtitus commented Jul 18, 2012

Copy link
Copy Markdown

No description provided.

@gpoore

gpoore commented Jul 18, 2012

Copy link
Copy Markdown
Owner

This looks good. I will merge soon.

Two questions: I would like to acknowledge you in the documentation. Is that acceptable? If so, what version of OS X and what version of Python are you using, so I can mention that in the documentation regarding compatibility?

@obtitus

obtitus commented Jul 19, 2012

Copy link
Copy Markdown
Author

Sure, Mac OS X 10.7.4, python 2.7.3.
Please note that I have not tested sympy and pygmens yet, but the install seems to work.

Question back to you: how do you maintain the different python version files, say I make an innocent change in pythontex2.py do I have to make the same change manually in pythontex3.py? Or do you have a script for this?

On 19. juli 2012, at 00:05, gpoore wrote:

This looks good. I will merge soon.

Two questions: I would like to acknowledge you in the documentation. Is that acceptable? If so, what version of OS X and what version of Python are you using, so I can mention that in the documentation regarding compatibility?


Reply to this email directly or view it on GitHub:
#4 (comment)

@gpoore

gpoore commented Jul 19, 2012

Copy link
Copy Markdown
Owner

I have a script that automatically converts from 2 to 3. Basically, any code that is only for one version has special comments around it. In the Python 2 version, the special Python 2 code is un-commented and the Python 3 version is commented out. The script un-comments the Python 3 version and comments out the Python 2 version.

The script is pythontex_2to3.py. I will put it up later today.

@gpoore

gpoore commented Aug 17, 2012

Copy link
Copy Markdown
Owner

I think I'm close to a solution regarding code that depends on external files. I think I can add something like pytex.add_external_dependency("ext_file1", "ext_file2", ...), and have PythonTeX automatically track changes in the code as well as changes in all user-specified external files. I'll see if I can get that up in the next week or so.

Can you explain the type of situation in which you need asynchronous plotting? The code you are using doesn't work under Windows (Windows has special multiprocessing restrictions, due to the lack of fork). Before I consider creating a truly cross-platform solution, I want to make sure I'm clear on the problem. If plots are slow, that could be because you are plotting a lot of data. But it could also just be because you are using matplotlib's LaTeX option, which can really slow things down. If the LaTeX option is the real issue, the simplest thing to do is to disable the LaTeX option until everything is in final form, then enable it for one last run.

Even if I don't go ahead with creating a cross-platform asynchronous plotting solution, I will modify the PythonTeX utilities class a little, so that scripts like your current async_pylab_save.py can be plugged right into the PythonTeX workflow, without requiring changes to pythontex_types2.py or any of the other PythonTeX scripts. Basically, I will make the utilities class provide an interface that imported packages can use if they need to run code automatically at the beginning or end of a session. So instead of having to modify pythontex_types2.py to add "aps.join()" to the end of each session, you can add a line like "pytex.cleanup.append("aps.join()")" somewhere in async_pylab_save.py.

@obtitus

obtitus commented Aug 17, 2012

Copy link
Copy Markdown
Author

Yes, I use the latex option and save a lot of figures with lots of data so the async_pylab_save.py really helps to speed things up. I am not particularly happy about a "final" version, as I always want the final version. I had some problems using a different backend then 'Agg', maybe you can try that.

When you say "track changes" would you look at the timestamp or read the entire file? (My files are big, so reading the entire file just to check for changes would be painfull).

It would be easier if the "setpythontexcustomcode" could also add stuff to the end of file, this way async_pylab_save.py can be seperate from pythontex.

Adding ""pytex.cleanup.append("aps.join()")" somewhere in async_pylab_save.py." won't work since async_pylab_save does not know about the pytex class.

On 17. aug. 2012, at 07:35, gpoore wrote:

I think I'm close to a solution regarding code that depends on external files. I think I can add something like pytex.add_external_dependency("ext_file1", "ext_file2", ...), and have PythonTeX automatically track changes in the code as well as changes in all user-specified external files. I'll see if I can get that up in the next week or so.

Can you explain the type of situation in which you need asynchronous plotting? The code you are using doesn't work under Windows (Windows has special multiprocessing restrictions, due to the lack of fork). Before I consider creating a truly cross-platform solution, I want to make sure I'm clear on the problem. If plots are slow, that could be because you are plotting a lot of data. But it could also just be because you are using matplotlib's LaTeX option, which can really slow things down. If the LaTeX option is the real issue, the simplest thing to do is to disable the LaTeX option until everything is in final form, then enable it for one last run.

Even if I don't go ahead with creating a cross-platform asynchronous plotting solution, I will modify the PythonTeX utilities class a little, so that scripts like your current async_pylab_save.py can be plugged right into the PythonTeX workflow, without requiring changes to pythontex_types.py or any of the other PythonTeX scripts. Basically, I will make the utilities class provide an interface that imported packages can use if they need to run code automatically at the beginning or end of a session. So instead of having to modify pythontex_types.py to add "aps.join()" to the end of each session, you can add a line like "pytex.cleanup.append("aps.join()")" somewhere in async_pylab_save.py.


Reply to this email directly or view it on GitHub.

@UweZiegenhagen

Copy link
Copy Markdown

I have a few issues running pythontex under Windows. I am now at the point, where pythontex.bat py1.tex throws:

C:\Users\Uwe\Documents\dokumente\LaTeX-snippets\Python>pythontex.bat py1.tex
This is PythonTeX v0.9beta3

  • PythonTeX error
    kpsewhich is not happy with its arguments.
    This command was attempted:
    kpsewhich --format texmfscripts pythontex_utils2.py

Since there is no pythontex.py, I adjusted the bat file to use Python 2. The TeX file contains:

\documentclass{article}
\usepackage{pythontex}
\begin{document}
\begin{pyconsole}
myvar =123
myvar + 1
\end{pyconsole}
\end{document}

Any ideas?

@gpoore

gpoore commented Sep 1, 2012

Copy link
Copy Markdown
Owner

UweZiegenhagen,

In the future, please open a new issue rather than reusing a pull request or issue that is already open...that makes it easier for me to keep track of things.

You're correct that the batch files needs to use pythontex2.py (or pythontex3.py); I've fixed that for the next release.

The error message means that kpsewhich returned an error while trying to find the location of pythontex_utils2.py. This is probably because it couldn't find pythontex_utils2.py. If you run the command "kpsewhich --format texmfscripts pythontex_utils2.py" from the command prompt, you should be able to determine if that is the case.

If kpsewhich can't find the file, then the file probably isn't where it should be. Which TeX distribution are you using? Is there anything special about how you have TeX installed? How did you install PythonTeX?

@UweZiegenhagen

Copy link
Copy Markdown

Sorry, I saw that after sending the comment. I completely ignored the installation instructions, now it works nicely. I guess I'll write an article on your work for the German TeX Users Group. Great job!

Uwe

@FGF

FGF commented Dec 24, 2012

Copy link
Copy Markdown

TexShop 3.11+ Texlive2012 + MacPro OS 10.8.2 Works fine.
Can it be possible to make a engine for texshop ?
mine :
#!/bin/bash
export LANG=en_US.UTF-8
export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/

pdflatex "$1"

PYTHON="/Library/Frameworks/Python.framework/Versions/Current/bin/python"
SCRIPT_PATH="/bin/pythontex.py"
$PYTHON $SCRIPT_PATH "$1"
pdflatex "${1%.*}"

Says:

This is PythonTeX v0.9beta3

---- Errors for pylab_default_0 ----
Traceback (most recent call last):

  • PythonTeX code error. Error line cannot be determined.
  • Error is likely due to system and/or PythonTeX-generated code.
    File "pythontex-files-test/pylab_default_0.py", line 10, in
    from pylab import *
    ImportError: No module named pylab
  • PythonTeX warning
    Could not parse stderr into a .stderr file
    The offending file was pythontex-files-test/pylab_default_0.err

PythonTeX: test - 1 error(s), 1 warning(s)

And I don't know why because if I do pythontex.py test.tex it works fine!

THANKS and Merry Christmas

@obtitus

obtitus commented Dec 24, 2012

Copy link
Copy Markdown
Author

Looks like you don't have matplotlib installed, you can either download it from http://matplotlib.org, or you may use pythontex without using the pylab family. I am guessing test.tex does not contain any pylab related stuff.

PS. Installing matplotlib manually can be a pain due to the dependencies, consider installing macport and running:
sudo port install py27-matplotlib texlive

@FGF

FGF commented Dec 24, 2012

Copy link
Copy Markdown

Thank you obtitus!
But, thats the problem, I have it installed. So I think. If I do python and in python I do import pylab and I can plot, thats an evidence that I have matplotlib installed isn't?

@gpoore

gpoore commented Dec 24, 2012

Copy link
Copy Markdown
Owner

FGF, do you have multiple Python installations, or are you using virtualenv or a similar tool? It appears that matplotlib isn't being found, so if you do have multiple versions etc., that could prevent matplotlib from being found. You have

export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/

and then

PYTHON="/Library/Frameworks/Python.framework/Versions/Current/bin/python"

I expect your problem is related to one of these lines.

In terms of a TeXShop engine, I'm afraid I can't help much with that, because I only have access to Windows and Linux machines. If you do create a good, generic engine (doesn't depend too much on your specific configuration), I could think about adding that to the distribution.

@gpoore gpoore closed this in 3ed6f63 Jan 10, 2013
@gpoore

gpoore commented Jan 10, 2013

Copy link
Copy Markdown
Owner

obtitus,

The latest commit should address almost everything you've brought up in this request.

  • The new installer attempts to create symlinks. It mostly keeps your approach for MacPorts TeX Live, and adds general support for TeX Live under Linux (and hopefully will work under others).
  • The PythonTeX scripts now return an exit code of 1 if there were errors. (There's a new command line option for turning this off if it is desired.)
  • You can now determine when code is executed again. See the new rerun and runall options. By default, sessions will only be executed again on the next run if they produce errors; warnings are ignored after their first appearance.
  • The PythonTeX utilities class now has a new method add_dependencies() that allows automatic tracking of dependencies. By default, this detects changes via mtime, but you can set it to use hashes (new option hashdependencies).
  • I've redone the treatment of custom code with a new command and a new environment. These allow custom code to be added to the beginning or end of a session.
  • I will keep thinking about ways to do async plotting, but since getting that to work cross-platform is tricky, I'm not planning anything in the immediate future. The revised treatment of custom code should give you what you need to work with your async script. Also, matplotlib 1.2 changed a lot of things, and among other things added a pgf backend. So that may affect approaches to plotting.

@obtitus

obtitus commented Jan 13, 2013

Copy link
Copy Markdown
Author

Looks great, after giving up trying to tell git to merge I deleted my own copy and made a new clone, seems to work fine (no extensive testing, but my thesis seems to compile fine after a few changes).

Love the new pythontexcustomcode environment, for reference here is my new interface to the async plotting lib (but matplotlib 1.2 seems promising):
\begin{pythontexcustomcode}[begin]{pylab}
from async_pylab_save import AsyncPylabSave
aps = AsyncPylabSave()
\end{pythontexcustomcode}
\begin{pythontexcustomcode}[end]{pylab}
aps.join()
\end{pythontexcustomcode}

I do have a question about some of the new output, but I will open a separate issue. Great work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants