Lua search paths

OpenSubmitted by raingloom.
Details
2 participants
  • raingloom
  • zimoun
Owner
unassigned
Severity
normal
Merged with
R
R
raingloom wrote on 15 Nov 2020 19:24
(name . Guix Bugs)(address . bug-guix@gnu.org)
20201115192441.0af831a5@riseup.net
I have a very WIP branch adding search paths to Lua.https://git.sr.ht/~raingloom/guix-source/tree/raingloom/lua
The problem is that Lua uses a different path format compared to mostpackages. Instead of a list of directories, it is a list of pathpatterns, each potentially containing a question mark ('?'), which getssubstituted for the module being searched.
For pure Lua modules, this basically means /lib/lua/5.3/?.lua and/lib/lua/5.3/?/init.lua.I am not aware of any practical use of paths that do not contain a '?',so there is a relatively easy solution here:use the string.gsub function to expand every path component that doesnot contain a '?' into two components, the ?.lua and the ?/init.lua one.This means externally defined components are not expanded, only theones defined by Guix.
For C modules, it's a bit trickier, because there is a specialcomponent that looks into loadall.so, which I must admit I'm notfamiliar with. As far as I know, popular modules all define their ownshared object file, never a loadall.so.
Also, the path is separated by semicolons, not colons, but I think Guixcan already handle that.
The approaches I see:- patch loadlib.c in Lua to expand LUA_PATH and LUA_CPATH according to the above mentioned heuristics, or- patch Guix to support paths of this format- define something like GUIX_LUA_PATH that gets expanded on its own and only contains Lua modules defined in Guix, and then gets appended to package.path (and do the same for package.path)

Solving this would open up access to the huge variety of Lua modulesand make things like game development in LÖVE much better integrated.Its users could even use `guix pack` to distribute their games.
Z
Z
zimoun wrote on 26 Mar 10:28 +0100
(name . raingloom)(address . raingloom@riseup.net)(address . 44662@debbugs.gnu.org)
86lfaa9sd8.fsf@gmail.com
Hi,
On Sun, 15 Nov 2020 at 19:24, raingloom <raingloom@riseup.net> wrote:
Toggle quote (8 lines)> I have a very WIP branch adding search paths to Lua.> https://git.sr.ht/~raingloom/guix-source/tree/raingloom/lua>> The problem is that Lua uses a different path format compared to most> packages. Instead of a list of directories, it is a list of path> patterns, each potentially containing a question mark ('?'), which gets> substituted for the module being searched.
From my understanding, it is a duplicate tohttp://issues.guix.gnu.org/issue/25425. Does it make sense to mergethem?

All the best,simon
R
R
raingloom wrote on 26 Mar 21:29 +0100
(address . 44662@debbugs.gnu.org)
20210326212949.5d954e44@riseup.net
On Fri, 26 Mar 2021 10:28:03 +0100zimoun <zimon.toutoune@gmail.com> wrote:
Toggle quote (19 lines)> Hi,> > On Sun, 15 Nov 2020 at 19:24, raingloom <raingloom@riseup.net> wrote:> > I have a very WIP branch adding search paths to Lua.> > https://git.sr.ht/~raingloom/guix-source/tree/raingloom/lua> >> > The problem is that Lua uses a different path format compared to> > most packages. Instead of a list of directories, it is a list of> > path patterns, each potentially containing a question mark ('?'),> > which gets substituted for the module being searched. > > From my understanding, it is a duplicate to> <<http://issues.guix.gnu.org/issue/25425>. Does it make sense to> merge them?> > > All the best,> simon
Yup, a merge seems to be in order.
Z
Z
zimoun wrote on 26 Mar 23:41 +0100
control message for bug #44662
(address . control@debbugs.gnu.org)
861rc1a66v.fsf@gmail.com
merge 44662 25425quit
?