Skip to main content

Use Python packages inside Lua scripts.

Project description

LuPack

Use any Python package directly inside your Lua scripts!

Built on top of LuaWrap.

Installation

pip install LuPack

How to Use

Python packages are injected into your Lua script and available as py_<packagename>.

Quickstart with lua_with()

Pass your package names in, get a runner back, then write Lua as normal:

from LuPack import lua_with

lua_with("math")("""
    local result = py_math.sqrt(144)
    print("Square root of 144 is: " .. result)
""")

Multiple packages at once

from LuPack import lua_with

lua_with("math", "os")("""
    print("Pi is: " .. py_math.pi)
    print("Current folder: " .. py_os.getcwd())
""")

Reuse the runner

from LuPack import lua_with

run = lua_with("math")

run("print(py_math.floor(3.9))")
run("print(py_math.sqrt(25))")

Full control with LuPackRuntime

from LuPack import LuPackRuntime

rt = LuPackRuntime()
rt.register("math")           # available as py_math in Lua
rt.register("os", "system")  # available as py_system in Lua

rt.run("""
    print(py_math.pi)
    print(py_system.getcwd())
""")

How packages are named in Lua

Python package Lua name
math py_math
os py_os
requests py_requests
os with alias "system" py_system

API

Tool What it does
lua_with("pkg1", "pkg2") Returns a runner with those packages injected
LuPackRuntime() Full runtime object for more control
rt.register("pkg") Inject a package into the runtime
rt.register("pkg", "alias") Inject with a custom Lua name
rt.run("...") Run Lua code with all registered packages

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

lupack-0.1.0.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lupack-0.1.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file lupack-0.1.0.tar.gz.

File metadata

  • Download URL: lupack-0.1.0.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.3 Windows/11

File hashes

Hashes for lupack-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e50978f4c3c879a4705d7dcadb3aeee4dd7ad9f1498951ad1cbe8ee6b407e8f4
MD5 171306b33cff431b9d1ccc9a6fb8fa8c
BLAKE2b-256 8336a6110967d8c52babe2e4777b0c64201c0b195c46f11bb8ca1204201cf700

See more details on using hashes here.

File details

Details for the file lupack-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lupack-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.3 Windows/11

File hashes

Hashes for lupack-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f672fc53e9b4cd99cdf5b88edb34426d65d3ce3212bcf24450db737a718c0e8
MD5 bad03d8bc5b478eb033b7fa19b8b1bcf
BLAKE2b-256 82ed8fb0b8b66265d9821f6bbbbb973673966506cf46e6c20268eee9bfe87159

See more details on using hashes here.

Supported by

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