forked from renpy/renios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_extend_inittab.py
executable file
·42 lines (27 loc) · 1.02 KB
/
generate_extend_inittab.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
import os
def main():
prototype = os.path.join(os.path.dirname(__file__), "prototype")
packages = os.path.join(prototype, "prebuilt/release/python/lib/python2.7/site-packages")
inittab = [ ]
for dn, dirs, files in os.walk(packages):
for fn in files:
if not fn.endswith(".so"):
continue
rn = os.path.relpath(os.path.join(dn, fn), packages)
modname = rn[:-3].replace("/", ".")
init = "init" + modname.split(".")[-1]
inittab.append((modname, init))
print """\
// Automatically generated by generate_extend_inittab.py
#include "Python.h"
"""
for _mod, init in inittab:
print "PyMODINIT_FUNC {}(void);".format(init)
print
print "void renios_extend_inittab(void) {"
for mod, init in inittab:
print ' PyImport_AppendInittab("{}", {});'.format(mod, init)
print "}"
if __name__ == "__main__":
main()