Unable to Import 'lua-utf8' in LuaJIT
exind opened this issue · comments
Thank you for creating and maintaining Lupa. Your efforts greatly enhance Python-Lua integration.
When attempting to import the Lua extension lua-utf8
within Python code utilizing the Lupa library, an error is encountered. The error message reports that the module lua-utf8
cannot be loaded due to an undefined symbol (lua_gettop
). However, when the same code is executed using the LuaJIT CLI, importing lua-utf8
functions seamlessly without any issues.
Steps to Reproduce:
- Initialize a Lupa Runtime backed by LuaJIT
- Try to Import
lua-utf8
usingrequire 'lua-utf8
- Observe the traceback error indicating the failure to load the 'lua-utf8' module.
import lupa.luajit21 as lupa
lua = lupa.LuaRuntime(unpack_returned_tuples=True)
lua.execute("""
require "lua-utf8"
""")
Traceback (most recent call last):
File "/home/someone/test.py", line 258, in <module>
lua.execute("""
File "lupa/luajit21.pyx", line 440, in lupa.luajit21.LuaRuntime.execute
File "lupa/luajit21.pyx", line 1821, in lupa.luajit21.run_lua
File "lupa/luajit21.pyx", line 1835, in lupa.luajit21.call_lua
File "lupa/luajit21.pyx", line 1861, in lupa.luajit21.execute_lua_call
File "lupa/luajit21.pyx", line 1743, in lupa.luajit21.raise_lua_error
lupa.luajit21.LuaError: error loading module 'lua-utf8' from file '/usr/local/lib/lua/5.1/lua-utf8.so':
/usr/local/lib/lua/5.1/lua-utf8.so: undefined symbol: lua_gettop
stack traceback:
[string "<python>"]:2: in main chunk
[C]: in function 'require'
[C]: at 0x7f87c7bb4530
Expected Behavior:
When using Lupa, importing the lua-utf8
module should work just like it does in LuaJIT CLI without any errors.
➜ ~ luajit
LuaJIT 2.1.1710088188 -- Copyright (C) 2005-2023 Mike Pall. https://luajit.org/
JIT: ON SSE3 SSE4.1 BMI2 fold cse dce fwd dse narrow loop abc sink fuse
> local utf8 = require "lua-utf8"
> print(utf8.len("Hello"))
5
>
Additional Information:
➜ ~ nm -D /usr/local/lib/lua/5.1/lua-utf8.so | grep lua_gettop
U lua_gettop
OS: Fedora Linux 39 (with 6.7.11-200.fc39.x86_64 kernel)
Python Version: 3.12.2
Lupa Version: 2.1
LuaJIT Version: LuaJIT 2.1.1710088188
Nevermind. not a problem from lupa side :)
Fixed by compiling the lua-utf8
from source and replacing lua-utf8.so
file with new compiled file