Mercurial > hgrepos > FreeBSD > ports > PyPy
changeset 115:ce7e2a955814
Script to augment an existing PLIST with entries for byte-compiled files
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Wed, 10 Jan 2024 18:49:36 +0100 |
| parents | 8ae98a6ddf12 |
| children | 9da5f4f99951 |
| files | misc/augment_plist.py |
| diffstat | 1 files changed, 48 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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()
