import builtins
import inspect
import types
env = RelEnvironment()
template = env.get_template(templatefile)
export_dict = {}
export_dict.update(builtins.__dict__)
export_dict.update(types.__dict__)
export_dict.update(inspect.__dict__)
result = template.render(**export_dict)
Import a Python module into a Jinja template?