# HG changeset patch # User Franz Glasner # Date 1704908976 -3600 # Node ID ce7e2a9558148600a2ddcfa65d0d4c56c5ae3f47 # Parent 8ae98a6ddf12001d4979da0b3873f821b4044d51 Script to augment an existing PLIST with entries for byte-compiled files diff -r 8ae98a6ddf12 -r ce7e2a955814 misc/augment_plist.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/augment_plist.py Wed Jan 10 18:49:36 2024 +0100 @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +r"""Augment the current pkg-plist with entries for byte-compiled files. + +The result is written to stdout. + +Usage: augment_plist.py INPUT + +Python + +""" + +from __future__ import print_function, absolute_import + +import io +import os +import re +import sys + + +def main(): + + infile = sys.argv[1] + outlines = [] + + for line_orig in io.open(infile, encoding="us-ascii"): + outlines.append(line_orig) + line = line_orig.rstrip() + if not line: + continue + # + # NOTE: Sync with the "compileall" installation step in the Makefile + # + if re.search("/tests?/", line): + continue + + if line.endswith(".py"): + directory, filename = os.path.split(line) + base, ext = os.path.splitext(filename) + for opt in ("", ".opt-1", ".opt-2"): + outlines.append( + "%%BYTECOMPILE%%{directory}/__pycache__/{base}%%PYPY_BCTAG%%{opt}.pyc\n" + .format(directory=directory, base=base, opt=opt)) + for line in outlines: + sys.stdout.write(line) + + +if __name__ == "__main__": + main()