分发 Lua 和库的最佳方式是什么?
我正在考虑将当前嵌入 Python 解释器的程序移至使用 Lua。在Python中,使用modulefinder
、compileall
和zipfile
来制作一个包含所有使用的外部库的整洁的zip文件是相当容易的。
Lua 是否有能力像这样捆绑它的库,或者是否有一些更好的最佳实践来分发嵌入 Lua 的程序?
I'm looking at moving a program that currently embeds a Python interpreter to use Lua. With Python it's fairly easy to use modulefinder
, compileall
, and zipfile
to make a nice tidy zip containing all the external libraries used.
Does Lua have the ability to bundle up its libraries like that, or is there some better best practice for distributing programs that embed Lua?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 Lua 的典型情况一样,没有一个标准,很多人都推出了自己的标准。
人们正在努力标准化一个名为 Lua Rocks 的包管理系统,但我不确定背后有多少动力它或者它有多成熟。 (2008 年,它还没有完全准备好进入黄金时段,但情况可能已经发生了变化。)
我自己的技术含量很低:如果我想分发一些东西,我只需将我的 Lua 源代码转换为 C 文件并将它们与二进制文件链接起来。查找并转换所有模块对我来说可能有点乏味,但对我的用户来说却是最简单的事情——他们甚至不需要知道涉及到 Lua。我已在 Pastebin。我可以选择编译,但我通常不编译,因为结果不可移植,而且 Lua 编译器无论如何都太快了。
如果有更自动化的东西就好了。我认为编写和调试一个好的工具可能需要几天的时间。
Lua 邮件列表上的人们肯定会了解更多。
As is typical with Lua, there's no one standard and a lot of people roll their own.
There's an effort to standardize on a package-management system called Lua Rocks, but I'm not sure how much momentum is behind it or how mature it is. (In 2008 it was not quite ready for prime time, but things may have changed.)
I myself am very low tech: if I want to distribute something, I just turn my Lua sources into C files and link them in with the binary. Finding and converting all the modules could be a bit tedious for me, but quite the easiest thing for my users—they don't even need to know that Lua is involved. I've posted a copy of my
lua2c
script at Pastebin. I have the option of compiling but I generally don't compile because the results are not portable and because the Lua compiler is so fast anyway.It would be nice to have something more automated. I think it would probably take several days to write and debug a good tool.
People on the Lua mailing list will surely know more.
如果是纯Lua,你也可以考虑使用 squish
它是一个打包所有Lua源码的工具将多个文件合并为一个文件,并提供 gzip/minify 选项。
If it is pure Lua, you might also consider using squish
It's a tool that packs all Lua source files into a single file, with options to gzip/minify it.