lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 8 March 2013 16:04, Peter Drahoš <drahosp@gmail.com> wrote:
> You can do that with LuaDist already as mentioned in the previous posts. However if this is to be automated LuaDist needs to know what to install, for that we need smartlua which will look at your app and install the needed dependencies that are not present. Bad news is that package names do not match require names so smartlua cannot directly use LuaDist to install "socket" as it does not exist.

Good news, everyone! I have implemented this functionality in a new
package for LuaDist - intellua [1]. The package automatically handles
installation of packages that you require but do not have installed.

The usage is really simple:

        require = require "intellua"

The new require function will first try if the package can be loaded.
If it fails, it looks up the module in a built-in preprocessed
database of module-name -> package-name mappings and install it
in-process using LuaDist. The module is then required again, so it is
directly available to the application as if the package was always
available. It correctly handles dependencies, i.e.:

	> require "moon"
	Finding out available versions of moonscript...
	Getting moonscript-0.2.2 (binary)...
	Finding out available versions of lpeg...
	Getting lpeg-0.10.2 (binary)...
	Finding out available versions of alt-getopt...
	Getting alt-getopt-0.7 (binary)...

The built-in database even handles the case where a module is provided
by multiple packages and prompts the user:

	> require "mapm"
	The module "mapm" is provided by the following packages: lmapm mapm
	Choose package to install: lmapm
	Finding out available versions of lmapm...
	Getting lmapm-5.1 (binary)...

The downside is that the database must be maintained manually and is
error-prone. A more robust way of building the database is on the way.

Suggestions/improvements are welcome.

[1] https://github.com/LuaDist/intellua