Lua相当于virtualenv?

发布于 2024-10-05 23:06:25 字数 1536 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

迷爱 2024-10-12 23:06:25

通过设置 LUA_PATH 环境变量,在 Lua 安装之间切换应该相当简单。引用 Lua 文档中的此页面

要确定其路径,require 首先检查全局变量 LUA_PATH。如果 LUA_PATH 的值为字符串,则该字符串就是路径。否则,require 检查环境变量 LUA_PATH。

[...]

路径中的组成部分用分号(大多数操作系统中很少用于文件名的字符)分隔。例如,如果路径是

<块引用>

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

然后调用 require"lili" 将尝试打开以下文件:

<块引用>

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

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

人疚 2024-10-12 23:06:25

[已存档] 你尝试过 LuaDist 吗?

它通过使用所谓的“部署”来解决这个问题——它是一个单独的目录,其中安装了所有依赖项和库(甚至 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.

我纯我任性 2024-10-12 23:06:25

看起来 vert 就是您正在寻找的内容。
就像 Python 中的 virtualenvwrapper 一样,它允许您定义一个独立的 Lua 环境。
此外,它可以从 luarocks 获得。

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.

南巷近海 2024-10-12 23:06:25

在Lua 5.1中有一个环境表,你可以将其放入全局变量中,然后使用该表加载字符串或文件作为_G,封装该文件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文