Python Forum
List all installed TeX packages in Linux
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
List all installed TeX packages in Linux
#1
Been doing some Latex lately, so I wrote this little script to list all the tex packages on my system
#!/usr/bin/env python3
# name: list-tex-packages.py
# author: Gribouillis  https://python-forum.io
# inspired by: https://tex.stackexchange.com/questions/125058
# requirement: plumbum, more_itertools
# LICENSE: MIT
from more_itertools import unique_everseen
from pathlib import Path
from plumbum import cli, local

__version__ = '2020.07.21'

def kpsepath():
    """List of potential directories where to find tex modules
    
    Usually contains the current directory '.'
    """
    L =  local["kpsepath"]('tex').strip().split(':')
    L = [x.lstrip('!').rstrip('/') for x in L]
    return L

def istyle_file(ipath=None):
    """Iterable of tex style files contained under one of the directories
    
    Arguments:
       ipath: iterable of directories where to find style files
       
    The search recurses the directories
    """
    def istyle_file():
        for p in (ipath or kpsepath()):
            if Path(p).is_dir():
                r = local['find'](p, '-name', '*.sty').strip().split('\n')
                yield from r
    return unique_everseen(istyle_file())

def itex_package(ipath=None):
    """Sorted list of the tex packages installed under the directories
    
    Arguments:
        ipath: iterable of directories where to find packages
    """
    def ipackage(ipath):
        for f in istyle_file(ipath):
            yield f.rsplit('/', 1)[-1].rsplit('.', 1)[0]
    return sorted(unique_everseen(ipackage(ipath)))

class App(cli.Application):
    """Print a list of installed tex packages on this computer"""
    VERSION = __version__
    def main(self):
        for x in itex_package():
            print(x)

if __name__ == '__main__':
    App().run()
Reply
#2
Haven't used it since creating https://github.com/Larz60p/MusicScales (in combination with Lisp)
Used to do all my documentation (1980's) in LaTex.
Very powerful.
Reply
#3
The biggest power of latex is that it can be generated by other programs...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  GUI list of installed packages Larz60+ 2 4,523 Oct-10-2016, 03:16 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020