开发者

Lua equivalent of virtualenv? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

开发者_运维问答

Closed 8 years ago.

Improve this question

Is there something like python's virtualenv in lua?

So I can install all required lua modules/rocks in a sandboxed environment. This is good for test, since I will not mess up with system-wide lua modules or another lua project's environment.

luarocks looks promising since its support of self-contained installation. But I'm interested that if there is some tool like virtualenv which automates the creation, maintenance and switch of sandboxed environments.


It should be fairly simple to switch between Lua installs by setting the LUA_PATH environment variable. Quoting this page from the Lua documentation:

To determine its path, require first checks the global variable LUA_PATH. If the value of LUA_PATH is a string, that string is the path. Otherwise, require checks the environment variable LUA_PATH.

[...]

The components in a path are separated by semicolons (a character seldom used for file names in most operating systems). For instance, if the path is

?;?.lua;c:\windows\?;/usr/local/lua/?/?.lua

then the call require"lili" will try to open the following files:

lili
lili.lua
c:\windows\lili
/usr/local/lua/lili/lili.lua


[archived] Have you tried LuaDist?

It solves exactly this issue by using so called 'deployments' - it is a single directory in which all dependencies and libraries (and even Lua interpreter) are installed, independent of the whole system.


It looks like vert is what you are looking for. Like virtualenvwrapper in Python, it allows you to define a self-contained Lua environment. Furthermore, it is available from luarocks.


In Lua 5.1 there is the environment table, which you can put in global variables and then load strings or files with that table as _G, encapsulating that file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜