allefeld / pytikz

A Python interface to TikZ
GNU General Public License v3.0
65 stars 11 forks source link

add noCache and useTemp options to constructor #1

Closed sspickle closed 4 years ago

sspickle commented 4 years ago

I love this package! However, I'm using pytikz to overlay drawings on top of images. This is not supported since the directory where pdflatex is run is created (by default) in an indeterminate location by tempfile. The useTemp option allows users to specify where the temp files are created. The noCache option just allows for the option to skip the caching of pdf files (if the image you're drawing on changes, it won't change the tik code, so the cache mechanism thinks that nothing has changed).

allefeld commented 4 years ago

Glad you like it, and thanks for contributing!

How do you include images? Wouldn't using absolute paths solve the tempdir problem? Which of course is awkward, but there could be a method on the Picture object to include an image, which interprets the path as relative to the current directory, and transforms that into an absolute path for the LaTeX code. And there could also be a mechanism to keep track of changed images to cache appropriately.

But that would be more extensive changes, and I don't see a problem with your proposed changes which solve the problem for you immediately. Just that I would prefer the name tempdir to useTemp, and cache=True to noCache=False – ok?

sspickle commented 4 years ago

Using absolute paths is really awkward since I'd have to edit the path every time I checked code out in a different directory.

No problem changing the names/logic, I'll do that and resubmit the PR.

Also, do you have any interest in submitting this to PyPI?

thanks! -steve

allefeld commented 4 years ago

Looking forward to the new PR!

PyPI: I thought about doing that eventually, and/or submitting to conda-forge. But to be honest, after a year of Python coding I think I have a pretty good grasp on the language and ecosystem, but I find Python packaging so absurdly confusing that I postponed that and settled for installation from GitHub instead. My setup.py is completely generic.

Plus, you may have noticed the submodule tikz.figure, which is incomplete and largely undocumented. The idea is not only to interface to TikZ, but use that as a foundation to create figures for scientific publications. So so far I planned to release when I'd gotten around to finish that.

Do you think tikz is good enough as it is to be released? If so, I probably would have to move tikz.figure into its own package.

allefeld commented 4 years ago

PS: Do you use \includegraphics or \pgfuseimage?

sspickle commented 4 years ago

Regarding PyPI, it's really up to you, of course! I like to use requirements.txt in all my project repositories to make it easy to create virtual environments that work with each repository. To get pytikz in requirements.txt right now I have to include a GitHub link with a hash. It's a bit awkward, but it works. It would be nice (someday!) to have a "real" project on PyPi that makes it easy to track versions, and suchlike.

I've been using \includegraphics. I wasn't aware of \pgfuseimage. I'll check into it.

-steve