AI functions fail in built executables (OSError "source code is not available")
jimkring opened this issue · 0 comments
jimkring commented
First check
- I added a descriptive title to this issue.
- I used the GitHub search to try to find a similar issue and didn't find one.
- I searched the Marvin documentation for this issue.
Bug summary
If using Marvin in a built executable application (e.g. built with Nuitka) then the source code will not be available and Marvin ai functions will fail when trying to get function signature and other information, when a call to inspect.getsource(func)
is made on the wrapped function. However, it appears that the source_code
is not used by the caller of the AI function, from what I can tell. As such, a reasonable fix might be to just set source_code
to None
if there is an error when calling inspect.getsource(func)
.
Reproduction
# install nuikta
pip install nuikta
# build a marvin example into an exe
python -m nuitka --standalone example.py
# run it
./example.dist/example.exe
# Note the error: OSError "source code is not available")
Error
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in main:52 │
│ │
│ in run:24 │
│ │
│ in sync_wrapper:614 │
│ │
│ in run_sync:106 │
│ │
│ in run:190 │
│ │
│ in run:118 │
│ │
│ in run_until_complete:654 │
│ │
│ in async_wrapper:570 │
│ │
│ in from_function_call:132 │
│ │
│ in from_function:89 │
│ │
│ in getsource:1258 │
│ │
│ in getsourcelines:1240 │
│ │
│ in findsource:1077 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
OSError: could not get source code
Versions
> marvin version
Version: 2.3.6
Python version: 3.11.4
OS/Arch: windows/amd64
Additional context
No response