exaloop/codon

module imports don't seem to work

Closed this issue · 3 comments

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'

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

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

@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