Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rpmlua wrapper command for running our Lua interpreter standalone #1867

Merged
merged 1 commit into from
Dec 17, 2021

Conversation

pmatilai
Copy link
Member

Being able to run stuff easily in rpm context helps developing and debugging
scriptlets and macros too. Supports running one-liner statements from
the cli, regular scripts and an interactive session.

This is placed into a separate executable for, well, separation and
simplicity, but it'll also give us means to link to readline without
dragging that to main rpm dependencies (but that's left for later).

@pmatilai pmatilai added RFE lua Lua bindings/interface labels Dec 17, 2021
@pmatilai
Copy link
Member Author

Sigh, CI acting up once more. Not going to let that spoil my day...

Being able to run stuff easily in rpm context helps developing and debugging
scriptlets and macros too. Supports running one-liner statements from
the cli, regular scripts and an interactive session.

This is placed into a separate executable for, well, separation and
simplicity, but it'll also give us means to link to readline without
dragging that to main rpm dependencies (but that's left for later).
@pmatilai
Copy link
Member Author

Couple of minor details fixed + realized that interactive mode is more useful if it's possible to enter it after executing a script...

@hroncok
Copy link
Contributor

hroncok commented Dec 17, 2021

Awesome, thank you!

To make ILua work I needed to execute a short snippet and execute a script from the given path. Looking at the code it seems that this is currently not possible to do? I could write a wrapper, but it would be easier if I could run:

$ rpmlua -e 'package.path =  os.getenv("LUA_PATH") .. ";" .. package.path' script.lua

@pmatilai
Copy link
Member Author

There you go: 59ef11f

I wasn't able to test it with iLua because all that does for me is traceback in slow-motion loop.

@pmatilai
Copy link
Member Author

Hmm, just realized another little thing to make it more like lua - with no arguments it should just enter interactive mode.

@pmatilai
Copy link
Member Author

...and now with readline support too. Suitably silly stuff to work on for the last day before holidays 😁

@hroncok
Copy link
Contributor

hroncok commented Dec 20, 2021

I wasn't able to test it with iLua because all that does for me is traceback in slow-motion loop.

That usually means the provided lua interpreter does not work with it.

@pmatilai
Copy link
Member Author

Possibly. I don't grok what iLua tries to do really, but for one rpm overrides package.path to its own location, which may interfere. I've no interest in chasing issues from running Lua through some funky Python wrapper 😅

@hroncok
Copy link
Contributor

hroncok commented Dec 20, 2021

I can definitively try it myself later, but basically what needs to be passed to ILua as -i value is a script that does:

#!/usr/bin/sh -eu
rpmlua -e 'package.path =  os.getenv("LUA_PATH") .. ";" .. package.path' "$*"

And if that command works as expected, so should ILua.

@hroncok
Copy link
Contributor

hroncok commented Dec 20, 2021

It works now with RPM from https://copr.fedorainfracloud.org/coprs/pmatilai/rpm-snapshot/ -- thanks!

@pmatilai
Copy link
Member Author

pmatilai commented Jan 3, 2022

Okay, glad it works for you. For me it (iLua) starts up, but trying to actually do anything there results in this traceback loop.

@hroncok
Copy link
Contributor

hroncok commented Jan 3, 2022

With:

Exception ZMQSocketChannel.get_msg() got an unexpected keyword argument 'block'

I seem to get that as well on rawhide, even with regular Lua. Will report that to iLua upstream.

jupyter/jupyter_console#241

@pmatilai
Copy link
Member Author

pmatilai commented Jan 3, 2022

Oh, I'm getting (on F35) this instead:

builtins.AttributeError: 'ILuaKernel' object has no attribute 'proto'

I was about to say "but it works with regular Lua", but then realized it works with rpmlua too if I pass absolute path to -i, I'd always happened to pass a relative path up to now.

@hroncok
Copy link
Contributor

hroncok commented Jan 26, 2022

iLua has been fixed on rawhide (Koji repo only for now).

$ mock -r fedora-rawhide-x86_64 --addrepo='https://download.copr.fedorainfracloud.org/results/pmatilai/rpm-snapshot/fedora-rawhide-$basearch/' --enablerepo=local install /usr/bin/rpmlua /usr/bin/ilua
$ mock -r fedora-rawhide-x86_64 shell --unpriv
...
<mock-chroot> sh-5.1$ cat rpmlua-wrapper 
#!/usr/bin/sh -eu
/usr/bin/rpmlua -e 'package.path =  os.getenv("LUA_PATH") .. ";" .. package.path' "$@"

<mock-chroot> sh-5.1$ ilua -i /builddir/rpmlua-wrapper
Jupyter console 6.4.0

ILua 0.2.1
In [1]: rpm.expand
Out[1]: <function 1>

In [2]: rpm.expand('%_arch')
Out[2]: "x86_64"

@pmatilai pmatilai deleted the rpmlua-pr branch February 2, 2022 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lua Lua bindings/interface RFE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants