Skip to content

Ability to run modules from packages #12

@XVilka

Description

@XVilka

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions