Import Lua modules directly from within Python.
Once lua_imports.lua_importer
has been registered, write an import
statement in your Python code, referring to your Lua module.
foo.lua
return {
say_hello = function(person)
print("Hello, " .. person)
end
}
bar.py
import foo
foo.say_hello("World")
lua_importer
may be registered within Python code:
from lua_imports import lua_importer
lua_importer.register()
(Note that this must come before any Lua imports)
Alternatively, to register lua_importer
environment-wide, create a lua-imports.pth
file in your environment's site-packages
folder with the following contents:
import lua_imports; lua_imports.lua_importer.register()
This module wraps Lupa, and so comes with all the same caveats about Lua vs. Python data types.
Install and update using pip:
pip install lua_imports