comparison lang/pypy3/misc/augment_plist.py @ 120:3b09db02a788

Move the old lang/pypy3 repo into the lang/pypy3 folder
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 12 Jan 2024 09:23:35 +0100
parents misc/augment_plist.py@ce7e2a955814
children
comparison
equal deleted inserted replaced
119:cbf8c9785be8 120:3b09db02a788
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()