Skip to main content

Import Lua modules directly from within Python

Project description

lua_imports

Import Lua modules directly from within Python.

Basic Usage

Once lua_imports.lua_importer has been registered, write an import statement in your Python code, referring to your Lua module.

Example

foo.lua

return {
    say_hello = function(person)
        print("Hello, " .. person)
    end
}

bar.py

import foo

foo.say_hello("World")

Registration

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()

Caveats

This module wraps Lupa, and so comes with all the same caveats about Lua vs. Python data types.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lua_imports-1.0.0.tar.gz (2.0 kB view hashes)

Uploaded Source

Built Distribution

lua_imports-1.0.0-py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page