Open kalekje opened 3 years ago
Quite some time ago I packed a subset of Penlight along with other Lua modules using https://github.com/mihacooper/luacc and I think it should still be reasonably easy to do something like this if you need to.
@catwell Can you show how to do it?
Another tool for this is squish
@catwell Can you show how to do it?
Yes, here is an example for just stringx (which depends on utils and compat).
First (this is a trick because luacc expects a main script) create a file that just contains do end
, call it empty.lua
and put it the lua
directory of Penlight sources (there are other solutions, this is the simplest to explain).
Then run:
lua bin/luacc.lua \
-o penlight-amalg.lua -i "/path/to/Penlight/lua" \
"empty" "pl.compat" "pl.utils" "pl.stringx"
You can now do this:
luacc
won't do any automagic dependency resolution, you have to do it manually, but I personally prefer this as it makes the build more robust...
@catwell Can you show how to do it?
Yes, here is an example for just stringx (which depends on utils and compat).
First (this is a trick because luacc expects a main script) create a file that just contains
do end
, call itempty.lua
and put it thelua
directory of Penlight sources (there are other solutions, this is the simplest to explain).Then run:
lua bin/luacc.lua \ -o penlight-amalg.lua -i "/path/to/Penlight/lua" \ "empty" "pl.compat" "pl.utils" "pl.stringx"
You can now do this:
luacc
won't do any automagic dependency resolution, you have to do it manually, but I personally prefer this as it makes the build more robust...
thank you very much
@myselfghost feel free to download penlight.lua
from here: https://github.com/kalekje/penlight
Otherwise, I had luck following these steps.
luacc
(https://github.com/mihacooper/luacc) repo and all dependencies with either luarocks or just unzipping the packages the same working folder (what I did)penlightReturnImportInto.lua
contain this line of code: return require('pl.import_into')()
lualatex/texlua
distribution. You should have luck replacing it with lua
):
texlua luacc.lua -o penlight.lua penlightReturnImportInto pl.xml pl.app pl.array2d pl.class pl.compat pl.comprehension pl.config pl.data pl.Date pl.dir pl.file pl.func pl.import_into pl.init pl.input pl.lapp pl.lexer pl.List pl.luabalanced pl.Map pl.MultiMap pl.operator pl.OrderedMap pl.path pl.permute pl.pretty pl.seq pl.Set pl.sip pl.strict pl.stringio pl.stringx pl.tablex pl.template pl.test pl.text pl.types pl.url pl.utils
After you have penlight.lua
, as long as it's in path, useage is simply pl = require'penlight'
.
Adding a build rule to the Penlight sources for a single-file version is something I would consider if you want to keep this open. There is probably still room for your LuaLaTeX specific packaging repo, but a single file version could have other utility and building it in CI and attaching it to releases is something we could look into.
Okay I can re-open it--I had closed it because I found a solution, but it does seem like there is some general interest in this.
I'm sorry that this isn't an issue per se but more of a query. I am looking into deploying penlight as a LaTeX library, however most TeX distributions prefer a small number of files and non generic (ie. init.lua in penlight would be problematic). Ideally, a single file version of penlight would solve this problem. Just curious if anyone here has merged the penlight modules into a single file, or has had luck using any existing tools (amalg, many2one)?
Thank you