lymp icon indicating copy to clipboard operation
lymp copied to clipboard

Ability to run modules from packages

Open XVilka opened this issue 7 years ago • 0 comments

Currently if I have 'mypkg' directory with 'init.py' and 'mymod.py' with 'myfunc' in it - it fails to get the function from the main. I use

let py_entrypoint pymod =
   get_string pymod "myfunc"

let py = Lymp.init ~exec:interpreter tmp_scripts_path in
let result = match (Int32.to_int script.typ) with
   | Some 1 -> (* Python snippet *)
        let snippet = get_module py mname in
        (* run snippet entry point *)
        let res = py_entrypoint snippet in
        close py;
        res
    | Some 2 -> (* Python ZIP of the module *)
        (* call unzip first *)
        exec_unzip ~dpath:tmp_scripts_path ~fpath:spath;
        let modname = mname ^ ".mymod" in
        let pymodule = get_module py modname in
        (* run module entry point *)
        let res = py_entrypoint pymodule in
        close py;
        res

if I change it to the "mymod.myfunc" in "py_entrypoint" - it still fails

XVilka avatar Mar 15 '18 09:03 XVilka