TeX Live and MacTeXScript to download TeX Live Packages "on the fly" (ver 1.20)

Information and discussion about TeX Live distribution for all platforms (Windows, Linux, Mac OS X) and the related MacTeX: installing, updating, configuring
Post Reply
TheMinotaur
Posts: 4
Joined: Sun Sep 18, 2011 8:40 pm

Script to download TeX Live Packages "on the fly" (ver 1.20)

Post by TheMinotaur »

From reading the forums and groups, I gather that a lot of us miss the "download on the fly" feature offered by MiKTeX. I've written a script that should allow us to do just that. Make sure you have python (most OS X and linux distributions provide it by default; if not, you can get either the 2 or 3 version from here), then run the command

Code: Select all

texliveonfly.py [options] file.tex
or, for python 3,

Code: Select all

python3 texliveonfly.py [options] file.tex
instead of "lualatex" or "pdflatex". The current options are:

Code: Select all

Options:
  --version             show program version number and exit
  -h, --help            print this help text and exit
  -c COMPILER, --compiler=COMPILER
                        your LaTeX compiler; defaults to pdflatex
  -a ARGS, --arguments=ARGS
                        arguments to pass to compiler; default is: "-synctex=1
                        -interaction=nonstopmode"
  --texlive_bin=LOCATION
                        Custom location for the TeX Live bin folder
  --terminal_only       Forces us to assume we can run only in this terminal.
                        Permission escalators will appear here rather than
                        graphically or in a new terminal.
  -s OPTION, --speech_when=OPTION
                        Toggles speech-synthesized notifications (where
                        supported).  OPTION can be "always", "never",
                        "installing", "failed", or some combination.
  -f, --fail_silently   If tlmgr cannot be found, compile document anyway.
Setting this command within your favourite editor will allow you to download packages on the fly. The script defaults to PdfLaTeX with arguments '-synctex=1 -interaction=nonstopmode'.

As of the Sep 27 version, the script should be compatible with either python 2 or 3. It depends strongly on the TeX Live Package Manager (tlmgr), so please make sure you are using at least TeX Live 2010. It should resolve all missing included packages and a fair number of missing fonts. It was written on Ubuntu 10.04 and should work on all Linux systems; the Sep 26th version should also work on OS X (but hasn't been tested as of this posting).

Any comments, suggestions, or bug reports are appreciated, and I hope you enjoy.
Updates:
  • September 19, 2011: Added options and changed name (lualatexonfly was no longer an accurate description).
  • September 24, 2011: Core functionality remains unchanged, but a lot of minor improvements!
    1. Now displays output from the compiler, as well as allowing the user to interact with the compiler (i.e. interaction=nonstopmode is no longer your only option).
    2. Now inherits the compiler's exit code (so that programs depending on it work more consistently)
    3. Slightly improved messages for user.
    4. Script now fails more gracefully under certain circumstances.
    5. SHOULD now work on OS X (need someone to actually test!)
  • September 25, 2011: Minor code restructuring and bugfixes from the Sep 24th version, but most importantly:
    1. Changed the option --engine/-e to --compiler/-c. (It's more intuitive, and we'll make sure not to use the compiler module!)
  • September 26, 2011: Fixed OS X package downloading bug. Still needs testing, however.
  • September 27, 2011: Script should now be compatible with python 2 (my best guess is: python 2.4+)! The #!/usr/bin/env line now calls "python" rather than "python3".
  • October 1, 2011: Version 1.00 released! Please note:
    • Default compiler is now pdflatex, to cater to the mainstream user. However, this and the default arguments can now easily be changed at the top of the script.
    We also have several improvements:
    1. Privilege escalation is now graphical (except for failsafes) and only happens if we need it.
    2. New options, --texlive_bin=LOCATION and --terminal_only (e.g. when you only have a terminal interface). The former allows the script to work on local installs, even when you don't have access to sudo.
    3. OS X support should be solidified (though field testing still requested).
    4. Code cleanup.
  • October 3, 2011: Version 1.10
    1. kdesudo added to list of permission escalators
    2. Can now provide verbal updates via platform's speech synthesizer. This can be turned toggled via --speech_when=always/installing/failed/some combination.
  • October 4th, 2011: Version 1.2. Script was largely changed from an object-oriented to functional style, which here makes a bit more sense. Minor fixes.
Last edited by TheMinotaur on Sun Oct 02, 2011 6:39 pm, edited 15 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
TheMinotaur
Posts: 4
Joined: Sun Sep 18, 2011 8:40 pm

Script to download TeX Live Packages "on the fly" (ver 1.20)

Post by TheMinotaur »

The September 24, 2011 version should now work with OS X, if I've gotten all the commands correct. However, lacking a mac, I've not been able to test it per se :(

Any volunteers appreciated! :D
TheMinotaur
Posts: 4
Joined: Sun Sep 18, 2011 8:40 pm

Script to download TeX Live Packages "on the fly" (ver 1.20)

Post by TheMinotaur »

Version 1.20 has been released. Bugs permitting, this may be the final version.

In summary, the script now:
  • Calls pdflatex by default (though defaults can now be easily changed at the top of the script)
  • Should run both on Linux and OS X
  • Is compatible both with python 2 and 3
  • Allows you to set the compiler, arguments, and custom location for the TeX Live bin folder
  • If your TeX editor does not output live updates, the wait can be unnerving. You can now set speech-synthesized notifications of download progress via, for example, --speech_when=installing
Testing and feedback are, as always, appreciated. Once again, enjoy!
Hadi Safi aghdam
Posts: 2
Joined: Sat Nov 24, 2012 11:36 am

Script to download TeX Live Packages "on the fly" (ver 1.20)

Post by Hadi Safi aghdam »

hello
very thanks for this script.
i test this in windows. (i saw that your script work on linux\mac)
i get error:

Code: Select all

C:\Users\hadi\Desktop\texliveon-fly\test2>python texliveonfly.py test.tex
Traceback (most recent call last):
  File "texliveonfly.py", line 58, in <module>
    def generateSudoer(this_terminal_only = False,  tempDirectory = os.path.join
(os.getenv("HOME"), ".texliveonfly") ):
  File "C:\progs\Python26\lib\ntpath.py", line 96, in join
    assert len(path) > 0
TypeError: object of type 'NoneType' has no len()

C:\Users\hadi\Desktop\texliveon-fly\test2>
have any way to use this script in windows?
if no, you can write this script for windows with money please?
Post Reply