diff lang/pypy2/misc/augment_plist.py @ 126:1c224aaef1af

Now also include the byte-compiled Python files (.pyc, .pyo) by default
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 14 Jan 2024 00:22:39 +0100
parents lang/pypy3/misc/augment_plist.py@3b09db02a788
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lang/pypy2/misc/augment_plist.py	Sun Jan 14 00:22:39 2024 +0100
@@ -0,0 +1,46 @@
+# -*- 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?/|tools/make_ssl_data.py", line):
+            continue
+
+        if line.endswith(".py"):
+            for compiled_suffix in ('c', 'o'):
+                outlines.append(
+                    "%%BYTECOMPILE%%{line}{compiled_suffix}\n"
+                    .format(line=line, compiled_suffix=compiled_suffix))
+    for line in outlines:
+        sys.stdout.write(line)
+
+
+if __name__ == "__main__":
+    main()