[tex-live] Package preparation question (directory structure)

Urs Liska ul at openlilylib.org
Mon Sep 9 01:15:56 CEST 2013

Am 08.09.2013 00:25, schrieb Karl Berry:
>      will have a 'lily-' prefix which is less ugly than lgl- and should
>      definitely be sufficient with regard to unique file-names.
> Unless there are other Lilypond-related packages (not in TeX) which use
> such names ...  That's why the ugly lgl- came to mind.

I think (speaking as a LilyPond power-user (not -developer)) I will take 
this responsibility, except there are severe objections now.

>      Exactly, this is 'import'ed by the other scripts.  I do not see why
>      this complicates things,
> Because the gen*Command scripts will be in the bin/ directory, but
> lilyglyphs_common.py should not be, since it's not meant to be invoked
> directly.  PATH directories should not be cluttered with
> non-user-level-executables.
> ...
> I think the most reliable way to find it is by running something like
> (sh-ish syntax for example):
> com=`kpsewhich --progname=lilyglyphs --format=texmfscripts lilyglyphs_common.py`
> And then read in $com.  I don't know how hard or easy that may be in the
> Python world.

I had suspected that kind of thing should _not_ be too hard in the 
Python world, and it seems I was right :-)
Although I probably wouldn't have easily found out about the exact 
kpsewhich call.

import os, sys
# import common library, depending on its location
scr_path, scr_name = os.path.split(sys.argv[0])
if not 'lilyglyphs_common.py' in os.listdir(scr_path):
     # the library is not in the same dir as the script
     # so we assume we're in a TeX installation.
         # use TeX's kpsewhich tool to locate the library file
         # in the TeX installation
         import subprocess
         lib = subprocess.check_output(["kpsewhich",
         print '\nCommon library \"lilyglyphs_common.py\" not found.'
         print 'Please refer to the manual for possible solutions.'
     # add the found path to Python's search path
import lilyglyphs_common

What I did to verify is:
- rename the lib in my project folder (so it isn't found by default)
- copy it to texmf-dist/scripts/lilyglyphs/lilyglyphs_common.py in my 
TeXLive installation (Linux)
- run texhash
- run the above code

I don't have the means right now to do more thorough tests but AFAICS 
this should work.

Do you think the issue is general enough to justify a self-answered 
question on stackoverflow to help someone running into a similar situation?

I can't believe this might have been the last real obstacle (apart from 
several minor TODOs).

Best and thank you for your assistance
> Hope this helps,
> karl

More information about the tex-live mailing list