summaryrefslogtreecommitdiffstats
path: root/Python/freeze_importlib.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-06-19 20:29:35 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-06-19 20:29:35 (GMT)
commite67f48ce5e7ad122b17e23b2705bf66cff76d42b (patch)
treee833621d743bfe9a83fb90e28f3b24f1a9829a45 /Python/freeze_importlib.py
parent0006aacb9dda6d62013c86aac47d977b3f04921a (diff)
downloadcpython-e67f48ce5e7ad122b17e23b2705bf66cff76d42b.zip
cpython-e67f48ce5e7ad122b17e23b2705bf66cff76d42b.tar.gz
cpython-e67f48ce5e7ad122b17e23b2705bf66cff76d42b.tar.bz2
Issue #14928: Fix importlib bootstrap issues by using a custom executable (Modules/_freeze_importlib) to build Python/importlib.h.
Diffstat (limited to 'Python/freeze_importlib.py')
-rw-r--r--Python/freeze_importlib.py39
1 files changed, 0 insertions, 39 deletions
diff --git a/Python/freeze_importlib.py b/Python/freeze_importlib.py
deleted file mode 100644
index 14a044d..0000000
--- a/Python/freeze_importlib.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /usr/bin/env python
-"""Freeze importlib for use as the implementation of import."""
-import marshal
-
-
-header = """/* Auto-generated by Python/freeze_importlib.py */"""
-
-
-def main(input_path, output_path):
- with open(input_path, 'r', encoding='utf-8') as input_file:
- source = input_file.read()
-
- code = compile(source, '<frozen importlib._bootstrap>', 'exec')
-
- lines = [header]
- lines.append('unsigned char _Py_M__importlib[] = {')
- data = marshal.dumps(code)
- # Code from Tools/freeze/makefreeze.py:writecode()
- for i in range(0, len(data), 16):
- line = [' ']
- for c in data[i:i+16]:
- line.append('%d,' % c)
- lines.append(''.join(line))
- lines.append('};\n')
- with open(output_path, 'w', encoding='utf-8') as output_file:
- output_file.write('\n'.join(lines))
- # Avoid a compiler warning for lack of EOL
- output_file.write('\n')
-
-
-if __name__ == '__main__':
- import sys
-
- args = sys.argv[1:]
- if len(args) != 2:
- print('Need to specify input and output file paths', file=sys.stderr)
- sys.exit(1)
-
- main(*args)