comparison misc/augment_plist.py @ 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
children
comparison
equal deleted inserted replaced
114:8ae98a6ddf12 115:ce7e2a955814
1 # -*- coding: utf-8 -*-
2 r"""Augment the current pkg-plist with entries for byte-compiled files.
3
4 The result is written to stdout.
5
6 Usage: augment_plist.py INPUT
7
8 Python
9
10 """
11
12 from __future__ import print_function, absolute_import
13
14 import io
15 import os
16 import re
17 import sys
18
19
20 def main():
21
22 infile = sys.argv[1]
23 outlines = []
24
25 for line_orig in io.open(infile, encoding="us-ascii"):
26 outlines.append(line_orig)
27 line = line_orig.rstrip()
28 if not line:
29 continue
30 #
31 # NOTE: Sync with the "compileall" installation step in the Makefile
32 #
33 if re.search("/tests?/", line):
34 continue
35
36 if line.endswith(".py"):
37 directory, filename = os.path.split(line)
38 base, ext = os.path.splitext(filename)
39 for opt in ("", ".opt-1", ".opt-2"):
40 outlines.append(
41 "%%BYTECOMPILE%%{directory}/__pycache__/{base}%%PYPY_BCTAG%%{opt}.pyc\n"
42 .format(directory=directory, base=base, opt=opt))
43 for line in outlines:
44 sys.stdout.write(line)
45
46
47 if __name__ == "__main__":
48 main()