#!/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()
#!/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()
#!/usr/bin/env python \ // Automatically generated by generate_extend_inittab.py #include "Python.h"