LaTeX forum ⇒ 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
TheMinotaur
Posts: 4
Joined: Sun Sep 18, 2011 8:40 pm

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

Postby TheMinotaur » Sun Sep 18, 2011 9:00 pm

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
  1. texliveonfly.py [options] file.tex

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

instead of "lualatex" or "pdflatex". The current options are:
  1. Options:
  2. --version show program version number and exit
  3. -h, --help print this help text and exit
  4. -c COMPILER, --compiler=COMPILER
  5. your LaTeX compiler; defaults to pdflatex
  6. -a ARGS, --arguments=ARGS
  7. arguments to pass to compiler; default is: "-synctex=1
  8. -interaction=nonstopmode"
  9. --texlive_bin=LOCATION
  10. Custom location for the TeX Live bin folder
  11. --terminal_only Forces us to assume we can run only in this terminal.
  12. Permission escalators will appear here rather than
  13. graphically or in a new terminal.
  14. -s OPTION, --speech_when=OPTION
  15. Toggles speech-synthesized notifications (where
  16. supported). OPTION can be "always", "never",
  17. "installing", "failed", or some combination.
  18. -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.

Link:
BBcode:
HTML:
Hide post links
Show post links

TheMinotaur
Posts: 4
Joined: Sun Sep 18, 2011 8:40 pm

Postby TheMinotaur » Sat Sep 24, 2011 8:05 am

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

Link:
BBcode:
HTML:
Hide post links
Show post links

TheMinotaur
Posts: 4
Joined: Sun Sep 18, 2011 8:40 pm

Postby TheMinotaur » Wed Sep 28, 2011 11:25 am

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!

Link:
BBcode:
HTML:
Hide post links
Show post links

Hadi Safi aghdam
Posts: 2
Joined: Sat Nov 24, 2012 11:36 am

Postby Hadi Safi aghdam » Mon Feb 18, 2013 12:07 am

hello
very thanks for this script.
i test this in windows. (i saw that your script work on linux\mac)
i get error:
  1. C:\Users\hadi\Desktop\texliveon-fly\test2>python texliveonfly.py test.tex
  2. Traceback (most recent call last):
  3. File "texliveonfly.py", line 58, in <module>
  4. def generateSudoer(this_terminal_only = False, tempDirectory = os.path.join
  5. (os.getenv("HOME"), ".texliveonfly") ):
  6. File "C:\progs\Python26\lib\ntpath.py", line 96, in join
  7. assert len(path) > 0
  8. TypeError: object of type 'NoneType' has no len()
  9.  
  10. 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?

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “TeX Live and MacTeX”

Who is online

Users browsing this forum: No registered users and 1 guest