#!/usr/bin/env python3 def init(): pass def main(): mfp.setProgramName("me.fier.example") # Your domain/username and the name of your program # Some example code to test the functionality testpy = mfp.require("test") testpy.st = "Hello world" testpy.echo() # "Hello world" testpy["st"] = "Hello world 2" testpy.echo() # "Hello world 2" testpy = mfp.require("test") testpy.echo() # Will still be "Hello world 2", since the library has been required before. testpy = mfp.dofile(mfp.p(mfp.sd,"module","test.py")) # Same file as used for mfp.require testpy.echo() # Will be None, as it's a new instance of the library (dofile does not care) def bootstrap(name,modName): if name in globals(): return import sys, os, importlib if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): s = os.path.realpath(sys.executable) else: s = os.path.realpath(__file__) if not os.path.join(os.path.dirname(s),"module","py") in sys.path: sys.path = [os.path.join(os.path.dirname(s),"module","py")] + sys.path mod = importlib.import_module(modName); modl = mod.Bunch() mod.init(mod,modl,s,name) globals()[name] = mod; globals()[name + "l"] = modl bootstrap("mfp","me.fier.python") init() if __name__ == '__main__': main()