← All tasks
pythonscoder/lupa #278Not a task: already works

Loading C modules with pre-built wheels?

envgap__scoder__lupa-278

01 / FAILURE SIGNATURE

As reported upstream

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':
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
c8dd81c0da1c80bcd3dc731712719a6ca09b591e
Manifest
pyproject.toml
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

scoder/lupa #278 · read the original issue
Hi lupa maintainers!

I'm currently trying to update a decade-old Python project ([chdkptp.py](https://github.com/a-hurst/chdkptp-python), 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:

```python
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
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]