DEV Community

Water Run
Water Run

Posted on

luainstaller 2.0: Package Your .lua Scripts into Native Binaries

There are two ways to package .lua scripts into binaries: the traditional srlua, which concatenates the Lua interpreter with the code, and the more modern luastatic, which performs real compilation. However, each of them has its own problems:

  • srlua

    • Can only package a single .lua file
    • Requires manual compilation
  • luastatic

    • Requires a build environment
    • Linux-only

luainstaller is an open-source Python library that wraps precompiled srlua and provides support for luastatic. It can be used as a command-line tool, a graphical application, or via a Python library API, and includes dependency analysis and a single-file packaging engine. It works out of the box on both Windows and Linux.

man luainstaller
Usage is very simple. Suppose you have an entry script a.lua; a.lua depends on b.lua, b.lua depends on c.lua, and so on.
You do not need to manually compile srlua (or configure a luastatic environment), manually analyze dependencies, merge all code into a single .lua script (for srlua), and then invoke srlua or luastatic. You only need:

pip install luainstaller
Enter fullscreen mode Exit fullscreen mode

Then

luainstaller build a.lua
Enter fullscreen mode Exit fullscreen mode

And that’s it.
You do not even need to type commands in the terminal:

luainstaller-gui
Enter fullscreen mode Exit fullscreen mode

This will launch a Tkinter-based graphical interface that includes the basic functionality.
luainstaller also supports more parameters and features, including a logging system (recorded using SimpSave), selectable engines, and more.

Tkinter GUI

Refer to the detailed documentation on GitHub for complete usage instructions. If you find the project helpful, consider giving it a Star to show your support :-)

Top comments (0)