[arch-commits] Commit in texlive-music/trunk (PKGBUILD python3-compat.patch)

Jelle van der Waa jelle at archlinux.org
Fri Jun 12 20:04:25 UTC 2020


    Date: Friday, June 12, 2020 @ 20:04:24
  Author: jelle
Revision: 389059

Port lilyglyphs print statements to python3 to remove the python2 optdependency

Added:
  texlive-music/trunk/python3-compat.patch
Modified:
  texlive-music/trunk/PKGBUILD

----------------------+
 PKGBUILD             |   16 +-
 python3-compat.patch |  309 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 319 insertions(+), 6 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2020-06-12 18:21:12 UTC (rev 389058)
+++ PKGBUILD	2020-06-12 20:04:24 UTC (rev 389059)
@@ -4,18 +4,20 @@
 pkgname=texlive-music
 pkgver=2020.54758
 _revnr=${pkgver#2020.}
-pkgrel=1
+pkgrel=2
 pkgdesc="TeX Live - Music typesetting packages"
 license=('GPL')
 arch=(any)
 depends=('texlive-core')
-optdepends=('python2: for scripts from the lilyglyphs packages')
+optdepends=('python: for scripts from the lilyglyphs packages'
+            'fontforge: for scripts from the lilyglyphs packages')
 groups=('texlive-most')
 url='http://tug.org/texlive/'
-source=("https://sources.archlinux.org/other/texlive/$pkgname-$pkgver-src.zip" "$pkgname.maps")
+source=("https://sources.archlinux.org/other/texlive/$pkgname-$pkgver-src.zip" "$pkgname.maps" python3-compat.patch)
 options=('!emptydirs')
 sha256sums=('47f418d851a0f838c08be406135ef338533e32cf0bc9c4ffefeaa0139973e8f1'
-            '0b3cc045390e756eb9243c0acc99a48a9c02ddab4764f4a00f8c3170660f017f')
+            '0b3cc045390e756eb9243c0acc99a48a9c02ddab4764f4a00f8c3170660f017f'
+            'f439a94c93eca9fa7e1e52b9d1f6af2abb963b33978bdea4b6f893cd97562392')
 
 build() {
    for p in *.tar.xz; do
@@ -22,6 +24,10 @@
 	   bsdtar -xf $p
    done
    rm -rf {tlpkg,doc,source} || true
+
+   # Update print statements to Python 3
+   cd texmf-dist
+   patch -Np1 -i ${srcdir}/python3-compat.patch
 }
 
 package() {
@@ -42,8 +48,6 @@
    if [[ -d "$pkgdir"/usr/share/texmf-dist/scripts ]]; then
      find "$pkgdir"/usr/share/texmf-dist/scripts -type f -exec chmod a+x '{}' \;
    fi
-   # fix python2 command name in scripts.
-   sed -i 's/env python/env python2/' "$pkgdir"/usr/share/texmf-dist/scripts/lilyglyphs/*.py
    # script symlinks
    install -m755 -d "$pkgdir"/usr/bin
    ln -s /usr/share/texmf-dist/scripts/lilyglyphs/lily-glyph-commands.py "$pkgdir"/usr/bin/lily-glyph-commands

Added: python3-compat.patch
===================================================================
--- python3-compat.patch	                        (rev 0)
+++ python3-compat.patch	2020-06-12 20:04:24 UTC (rev 389059)
@@ -0,0 +1,309 @@
+diff -aur texmf-dist/scripts/lilyglyphs/lily-glyph-commands.py texmf-dist.new/scripts/lilyglyphs/lily-glyph-commands.py
+--- texmf-dist/scripts/lilyglyphs/lily-glyph-commands.py	2013-10-03 00:18:36.000000000 +0200
++++ texmf-dist.new/scripts/lilyglyphs/lily-glyph-commands.py	2020-06-12 21:28:27.383263794 +0200
+@@ -80,10 +80,10 @@
+         if not len(line):
+             # skip if cmd and glyph haven't been filled both
+             if not (entry['cmd'] and entry['element']):
+-                print 'Skip malformed entry \'' + entry['cmd'] + '\'. Please check input file'
++                print('Skip malformed entry \'' + entry['cmd'] + '\'. Please check input file')
+                 reset_entry()
+             else:
+-                print 'Read entry \'' + entry['cmd'] + '\''
++                print('Read entry \'' + entry['cmd'] + '\'')
+                 lg.in_cmds[entry['cmd']] = {}
+                 lg.in_cmds[entry['cmd']]['element'] = entry['element']
+                 lg.in_cmds[entry['cmd']]['type'] = entry['type']
+@@ -110,13 +110,13 @@
+ 
+     
+ def usage():
+-    print 'genGlyphCommands.py'
+-    print 'is part of the lilyglyphs package'
+-    print ''
+-    print 'Usage:'
+-    print 'Pass the name (without path) of an input definitions file'
+-    print '(this has to be located in the /stash_new_commands directory.'
+-    print 'Please refer to the manual (documentation/lilyglyphs.pdf).'
++    print('genGlyphCommands.py')
++    print('is part of the lilyglyphs package')
++    print('')
++    print('Usage:')
++    print('Pass the name (without path) of an input definitions file')
++    print('(this has to be located in the /stash_new_commands directory.')
++    print('Please refer to the manual (documentation/lilyglyphs.pdf).')
+ 
+ # ####################################
+ # Finally launch the program
+diff -aur texmf-dist/scripts/lilyglyphs/lilyglyphs_common.py texmf-dist.new/scripts/lilyglyphs/lilyglyphs_common.py
+--- texmf-dist/scripts/lilyglyphs/lilyglyphs_common.py	2014-03-12 23:37:31.000000000 +0100
++++ texmf-dist.new/scripts/lilyglyphs/lilyglyphs_common.py	2020-06-12 21:27:46.323032709 +0200
+@@ -232,7 +232,7 @@
+     """Removes unneccessary files from LilyPond compilation,
+     rename and remove the preview PDF files to the right directory."""
+ 
+-    print 'Clean up directories'
++    print('Clean up directories')
+     
+     # iterate through dir_lysrc
+     os.chdir(dir_lysrc)
+@@ -255,7 +255,7 @@
+     
+ def compile_lily_files():
+     """Compiles LilyPond files to """
+-    print 'Compile with LilyPond:'
++    print('Compile with LilyPond:')
+     for file in lily_files:
+         args = []
+         args.append("lilypond")
+@@ -265,7 +265,7 @@
+         args.append("-dno-point-and-click")
+         args.append(os.path.join(dir_lysrc, file + ".ly"))
+         subprocess.call(args)
+-        print ''
++        print('')
+ 
+ def generate_latex_commands():
+     """Generates the templates for the commands in a new LaTeX file.
+@@ -308,12 +308,12 @@
+     
+     in_file = os.path.normpath(in_file)
+ 
+-    print 'Read input file ' + in_file
++    print('Read input file ' + in_file)
+     
+     # check for existence of input file
+     if not os.path.exists(in_file):
+-                    print 'File ' + in_file + ' not found.'
+-                    print 'Please specify an input file'
++                    print('File ' + in_file + ' not found.')
++                    print('Please specify an input file')
+                     sys.exit(2)
+ 
+     fin = open(in_file,  'r')
+@@ -336,7 +336,7 @@
+     fout.write(latexfile_start_comment.replace('SCRIPT_NAME', script_name()))
+ 
+     # write out command definitions
+-    sorted_cmds = sorted(latex_cmds.iterkeys())
++    sorted_cmds = sorted(latex_cmds.keys())
+     for cmd_name in sorted_cmds:
+         for line in latex_cmds[cmd_name]['cmd']:
+             fout.write(line)
+diff -aur texmf-dist/scripts/lilyglyphs/lily-image-commands.py texmf-dist.new/scripts/lilyglyphs/lily-image-commands.py
+--- texmf-dist/scripts/lilyglyphs/lily-image-commands.py	2013-10-03 00:18:36.000000000 +0200
++++ texmf-dist.new/scripts/lilyglyphs/lily-image-commands.py	2020-06-12 21:28:21.669897962 +0200
+@@ -63,35 +63,35 @@
+ 
+ def main():
+     """Do the actual work of the script"""
+-    print ''
+-    print 'buildglyphimages.py,'
+-    print 'Part of lilyglyphs.'
+-    print ''
++    print('')
++    print('buildglyphimages.py,')
++    print('Part of lilyglyphs.')
++    print('')
+     
+     # set CWD and ensure the necessary subdirs are present
+     check_paths()
+-    print ''
++    print('')
+ 
+     # load and parse input file
+     lg.read_input_file(in_file)
+     read_entries()
+-    print ''
++    print('')
+ 
+     # generate LilyPond source files for each command
+     # and compile them
+     write_lily_src_files()
+-    print ''
++    print('')
+     lg.compile_lily_files()
+-    print ''
++    print('')
+     
+     # remove intermediate files and move pdfs to pdf directory
+     lg.cleanup_lily_files()
+-    print ''
++    print('')
+     
+     # generate latex commands and example code
+     # and write them to the output file
+     lg.generate_latex_commands()
+-    print ''
++    print('')
+     write_latex_file()
+ 
+     
+@@ -127,11 +127,11 @@
+ 
+ def read_entries():
+     """Parses the input source file and extracts glyph entries"""
+-    print 'Read entries of LilyPond commands:'
++    print('Read entries of LilyPond commands:')
+     for i in range(len(lg.definitions_file)):
+         if '%%lilyglyphs' in lg.definitions_file[i]:
+             i = read_entry(i)
+-    print lg.lily_files
++    print(lg.lily_files)
+ 
+ def read_entry(i):
+     """Reads a single glyph entry from the input file and stores it
+@@ -165,11 +165,11 @@
+     # read command name
+     line = lg.definitions_file[i].strip()
+     cmd_name = line[: line.find('=') - 1]
+-    print '- ' + cmd_name,
++    print('- ' + cmd_name, end=' ')
+     if is_protected:
+-        print '(protected and skipped)'
++        print('(protected and skipped)')
+     else:
+-        print '' #(for line break only)
++        print('') #(for line break only)
+ 
+     # read actual command until we find a line the begins with a closing curly bracket
+     i += 1
+@@ -193,7 +193,7 @@
+ 
+ 
+ def usage():
+-    print """buildglyphimages. Part of the lilyglyphs package.
++    print("""buildglyphimages. Part of the lilyglyphs package.
+     Parses a template file, creates
+     single .ly files from it, uses LilyPond to create single glyph
+     pdf files and set up template files to be used in LaTeX.
+@@ -204,7 +204,7 @@
+     For detailed instructions refer to the manual.
+     Usage:
+     buildglyphimages.py in-file-name.
+-    """
++    """)
+ 
+ def write_file_info(name, fout):
+     """Formats file specific information for the lilyPond source file"""
+@@ -225,22 +225,22 @@
+ 
+ def write_latex_file():
+     """Composes LaTeX file and writes it to disk"""
+-    print 'Generate LaTeX file'
+-    print lg.dir_cmd, in_basename
++    print('Generate LaTeX file')
++    print(lg.dir_cmd, in_basename)
+     lg.write_latex_file(os.path.join(os.getcwd(), lg.dir_cmd,  in_basename + '.tex'))
+ 
+ def write_lily_src_files():
+     """Generates one .ly file for each found new command"""
+     skip_cmds = []
+-    print 'Write .ly files for each entry:'
++    print('Write .ly files for each entry:')
+     for cmd_name in lg.in_cmds:
+-        print '- ' + cmd_name
++        print('- ' + cmd_name)
+         gen_src_name = os.path.join(lg.dir_lysrc, cmd_filename(cmd_name) + '.ly')
+         # handle existing commands
+         if os.path.exists(gen_src_name):
+             action = ''
+             while not (action == 'Y' or action == 'N'):
+-                action = raw_input('already present. Overwrite (y/n)? ')
++                action = input('already present. Overwrite (y/n)? ')
+                 action = action.upper()
+             if action == 'N':
+                 skip_cmds.append(cmd_name)
+@@ -281,7 +281,7 @@
+         fout.close()
+     
+     # remove skipped commands from in_cmds
+-    print skip_cmds
++    print(skip_cmds)
+     for cmd_name in skip_cmds:
+         del lg.in_cmds[cmd_name]
+         lg.lily_files.remove(cmd_filename(cmd_name))
+@@ -314,7 +314,7 @@
+     in_path, in_filename = os.path.split(in_file)
+     in_path = os.path.normpath(in_path)
+     if not (('lilyglyphs' in in_path) and (in_path.endswith('definitions'))):
+-        print 'File in the wrong location: ' + in_path
++        print('File in the wrong location: ' + in_path)
+         usage()
+         sys.exit(2)
+     in_basename, in_ext = os.path.splitext(in_filename)
+diff -aur texmf-dist/scripts/lilyglyphs/lily-rebuild-pdfs.py texmf-dist.new/scripts/lilyglyphs/lily-rebuild-pdfs.py
+--- texmf-dist/scripts/lilyglyphs/lily-rebuild-pdfs.py	2013-10-03 00:18:36.000000000 +0200
++++ texmf-dist.new/scripts/lilyglyphs/lily-rebuild-pdfs.py	2020-06-12 21:28:27.446597488 +0200
+@@ -54,9 +54,9 @@
+ 
+ def main():
+     """Main walk through the program"""
+-    print 'rebuild-pdfs.py'
+-    print 'regenerate all pdf images that are not present (anymore)'
+-    print ''
++    print('rebuild-pdfs.py')
++    print('regenerate all pdf images that are not present (anymore)')
++    print('')
+     
+     # Check if we are in a legal CWD and ensure a PDF subdir is present
+     check_paths()
+@@ -66,14 +66,14 @@
+ 
+     # is there anything to be done at all?
+     if len(src_files) == 0:
+-        print ''
+-        print 'No image files missing, nothing to be done.'
+-        print 'If you want to re-create pdfs, then delete them first'
++        print('')
++        print('No image files missing, nothing to be done.')
++        print('If you want to re-create pdfs, then delete them first')
+         sys.exit(0)
+-    print ''
+-    print 'Found ' + str(len(src_files)) + ' missing file(s).'
++    print('')
++    print('Found ' + str(len(src_files)) + ' missing file(s).')
+     for cmd in src_files:
+-        print '- ' + cmd
++        print('- ' + cmd)
+ 
+     # compile all LilyPond files without matching pdf
+     lg.lily_files = src_files
+@@ -86,7 +86,7 @@
+     """Compares the list of LilyPond source and resulting PDF files.
+        Returns a list of LilyPond source file basenames 
+        which don't have a corresponding PDF file"""
+-    print 'Reading file lists, counting missing pdf files'
++    print('Reading file lists, counting missing pdf files')
+     
+     # read existing .pdf files in lg.dir_pdfs
+     img_files = []
+@@ -114,21 +114,21 @@
+     """Checks if we're in the right CWD
+        and makes sure that there is a pdf output directory available"""
+ 
+-    print 'Checking directories ...'
++    print('Checking directories ...')
+     
+     # check the presence of the necessary subdirectories
+     ls = os.listdir('.')
+     if not 'generated_src' in ls:
+-        print 'No LilyPond source files directory found.'
+-        print 'Sorry, there is something wrong :-('
+-        print 'Current working directory is: ' + os.getcwd()
+-        print 'Please consult the manual.'
++        print('No LilyPond source files directory found.')
++        print('Sorry, there is something wrong :-(')
++        print('Current working directory is: ' + os.getcwd())
++        print('Please consult the manual.')
+         sys.exit(2)
+     if not 'pdfs' in ls:
+         os.mkdir('pdfs')
+     
+-    print '... done'
+-    print ''
++    print('... done')
++    print('')
+ 
+ 
+ # ####################################



More information about the arch-commits mailing list