exaloop / codon

A high-performance, zero-overhead, extensible Python compiler using LLVM
https://docs.exaloop.io/codon
Other
13.96k stars 498 forks source link

module imports don't seem to work #492

Closed nhumrich closed 7 months ago

nhumrich commented 8 months ago

Imports do not seem to work on a basic python project.

It is common for a python project to be packaged as a module. In order for imports to work correctly, typically the entry point script is a very basic python file that imports the main function from a module.

For example, my directory:

- root/
    - app/
        - __init__.py
        - main.py
    run.py

And in my run.py, I have:

from app import main

if __name__ == '__main__':
    main.run()

When I run this with codon: codon run run.py I get the following error:

run.py:1:17-21: error: cannot import name 'main' from 'app.__init__'
run.py:4:5-15: error: no module named 'main'
elisbyberi commented 8 months ago

@nhumrich Did you import main.py in app.__init__.py?

nhumrich commented 8 months ago

I tried doing that, and it didn't fix the problem.

elisbyberi commented 8 months ago

@nhumrich I can reproduce the following error if I don't import main.py in app.__init__.py:

run.py:1:17-21: error: cannot import name 'main' from 'app.__init__'
run.py:4:5-15: error: no module named 'main'

If I import it, the issue is no longer reproducible. Here is a minimal reproducible example: root.zip