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

Loading C modules with pre-built wheels? #278

Open
a-hurst opened this issue Feb 11, 2025 · 0 comments
Open

Loading C modules with pre-built wheels? #278

a-hurst opened this issue Feb 11, 2025 · 0 comments

Comments

@a-hurst
Copy link

a-hurst commented Feb 11, 2025

Hi lupa maintainers!

I'm currently trying to update a decade-old Python project (chdkptp.py, a Python wrapper for controlling Canon cameras with CHDK firmware remotely over USB) to work nicely on modern systems. chdkptp, the library that chdkptp.py is wrapping, consists of a C module and a bunch of Lua scripts.

To avoid needing to compile lupa from source (and work around the lack of older Lua versions on distros like Fedora, which only packages 5.4 whereas chdkptp needs 5.2 or 5.3), I was hoping to use the pre-built Lua binaries conveniently provided in recent releases of lupa. However, when I try to use them I get the following error:

Python 3.9.16 (main, Apr  4 2023, 19:57:17) 
[GCC 12.2.1 20221121 (Red Hat 12.2.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import chdkptp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/lbrf/.pyenv/versions/3.9.16/lib/python3.9/site-packages/chdkptp/__init__.py", line 1, in <module>
    from chdkptp.device import ChdkDevice, list_devices, DeviceInfo
  File "/home/lbrf/.pyenv/versions/3.9.16/lib/python3.9/site-packages/chdkptp/device.py", line 8, in <module>
    from chdkptp.lua import LuaContext, global_lua, parse_table
  File "/home/lbrf/.pyenv/versions/3.9.16/lib/python3.9/site-packages/chdkptp/lua.py", line 143, in <module>
    global_lua = LuaContext()
  File "/home/lbrf/.pyenv/versions/3.9.16/lib/python3.9/site-packages/chdkptp/lua.py", line 94, in __init__
    self._setup_runtime()
  File "/home/lbrf/.pyenv/versions/3.9.16/lib/python3.9/site-packages/chdkptp/lua.py", line 105, in _setup_runtime
    self._rt.execute("""
  File "lupa/lua52.pyx", line 441, in lupa.lua52.LuaRuntime.execute
  File "lupa/lua52.pyx", line 1872, in lupa.lua52.run_lua
  File "lupa/lua52.pyx", line 1886, in lupa.lua52.call_lua
  File "lupa/lua52.pyx", line 1913, in lupa.lua52.execute_lua_call
  File "lupa/lua52.pyx", line 1794, in lupa.lua52.raise_lua_error
lupa.lua52.LuaError: error loading module 'chdkptp' from file '/home/lbrf/.pyenv/versions/3.9.16/lib/python3.9/site-packages/chdkptp/vendor/chdkptp/chdkptp.so':
        dynamic libraries not enabled; check your Lua installation
stack traceback:
        [string "<python>"]:2: in main chunk
        [C]: in function 'require'
        [C]: in ?

After a bit of searching I found #247 which seems to have added a context manager to allow loading Lua with module support, but even after updating the lupa import code with the below I still get the same error:

import lupa as lupa_main
with lupa_main.allow_lua_module_loading():
    import lupa.lua52 as lupa

Do the pre-compiled Lua versions in the Lupa wheels just not support dynamic libraries even with the recent fix, or am I doing something wrong? If the former, would it be possible to add dynamic library support to the pre-bundled wheels in a future release since it seems to be disabled by default anyway?

Thanks in advance!

  • Austin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant