hapy/importer.py
def make_module2(code: str, module_name: str):

    # NOTE: ERRORS IN MODULES DON'T MAKE THE PROGRAM TO FAIL!

    my_spec = util.spec_from_loader(module_name, loader=None)
    my_module = util.module_from_spec(my_spec)

    """
    THANK YOU JESUS! THIS THING SAVED THIS CODE!

    the challenge: adding sys to globals :/
    """
    my_module.__dict__["sys"] = sys

    # exec(code, my_module.__dict__)

    sys.modules[module_name] = my_module

    # lcls = {"sys": sys, "__name__": "__main__"}

    interpreter = _code.InteractiveInterpreter(locals=my_module.__dict__)

    # here, we are saying this guy come's from the main_string
    interpreter.runsource(code, '<the module file path>', 'exec')

    return """# --- import ---\n{m} = sys.modules["{m}"];\n# --- import ---"""\
        .format(** {"m": module_name})

    THANK YOU JESUS! THIS THING SAVED THIS CODE!

    the challenge: adding sys to globals :/
    
THANK YOU JESUS. THIS THING SAVED THIS CODE.
the challenge: adding sys to globals .
THANK YOU JESUS . THIS THING SAVED THIS CODE . the challenge : adding sys to globals .
def make_module2(code: str, module_name: str):
    my_spec = util.spec_from_loader(module_name, loader=None)
    my_module = util.module_from_spec(my_spec)
    my_module.__dict__["sys"] = sys
    sys.modules[module_name] = my_module
    interpreter = _code.InteractiveInterpreter(locals=my_module.__dict__)
    interpreter.runsource(code, '<the module file path>', 'exec')
    return """# --- import ---\n{m} = sys.modules["{m}"];\n# --- import ---"""\
        .format(** {"m": module_name})
def make_module2 ( code : str , module_name : str ) : my_spec = util . spec_from_loader ( module_name , loader = None ) my_module = util . module_from_spec ( my_spec ) my_module . __dict__ [ "sys" ] = sys sys . modules [ module_name ] = my_module interpreter = _code . InteractiveInterpreter ( locals = my_module . __dict__ ) interpreter . runsource ( code , '<the module file path>' , 'exec' ) return """# --- import ---\n{m} = sys.modules["{m}"];\n# --- import ---""" . format ( ** { "m" : module_name } )
THANK YOU JESUS!
THANK YOU JESUS!
# NOTE: ERRORS IN MODULES DON'T MAKE THE PROGRAM TO FAIL! """
    THANK YOU JESUS! THIS THING SAVED THIS CODE!

    the challenge: adding sys to globals :/
    """ # exec(code, my_module.__dict__) # lcls = {"sys": sys, "__name__": "__main__"} # here, we are saying this guy come's from the main_string
code
str
module_name
str