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

Compiling configuration does not work #732

Open
yamaguchi1024 opened this issue Oct 21, 2024 · 1 comment
Open

Compiling configuration does not work #732

yamaguchi1024 opened this issue Oct 21, 2024 · 1 comment
Labels
C: Codegen The final C code generation S: Available Available to be worked upon T: Bug Something isn't working

Comments

@yamaguchi1024
Copy link
Member

How to reproduce: put the following code in tmp.py and run exocc on it.

from __future__ import annotations
from exo import proc, config

@config
class Test:
    a: f32 

@proc
def foo(x: f32):
    Test.a = 32.0
    x = Test.a

print(foo)  
$ exocc tmp.py
Traceback (most recent call last):
  File "/Users/yuka/.venv/exo/bin/exocc", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/yuka/.venv/exo/lib/python3.12/site-packages/exo/main.py", line 58, in main
    for proc in get_procs_from_module(load_user_code(mod))
                                      ^^^^^^^^^^^^^^^^^^^
  File "/Users/yuka/.venv/exo/lib/python3.12/site-packages/exo/main.py", line 107, in load_user_code
    loader.exec_module(user_module)
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/Users/yuka/test/tmp.py", line 4, in <module>
    @config
     ^^^^^^
  File "/Users/yuka/.venv/exo/lib/python3.12/site-packages/exo/API.py", line 86, in config
    return parse_config(_cls)
           ^^^^^^^^^^^^^^^^^^
  File "/Users/yuka/.venv/exo/lib/python3.12/site-packages/exo/API.py", line 71, in parse_config
    body, getsrcinfo = get_ast_from_python(cls)
                       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yuka/.venv/exo/lib/python3.12/site-packages/exo/frontend/pyparser.py", line 47, in get_ast_from_python
    rawsrc = inspect.getsource(f)
             ^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 1285, in getsource
    lines, lnum = getsourcelines(object)
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 1267, in getsourcelines
    lines, lnum = findsource(object)
                  ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 1078, in findsource
    file = getsourcefile(object)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 955, in getsourcefile
    filename = getfile(object)
               ^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 924, in getfile
    raise TypeError('{!r} is a built-in class'.format(object))
TypeError: <class 'tmp.Test'> is a built-in class
@yamaguchi1024 yamaguchi1024 added the C: Codegen The final C code generation label Oct 21, 2024
@yamaguchi1024
Copy link
Member Author

The problem is that cls in parse_config does not have __file__ attribute, and this seems like a known issue in Python ( https://bugs.python.org/issue12920 )

@yamaguchi1024 yamaguchi1024 added T: Bug Something isn't working S: Available Available to be worked upon labels Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Codegen The final C code generation S: Available Available to be worked upon T: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant