nucleic / enaml

Declarative User Interfaces for Python
http://enaml.readthedocs.io/en/latest/
Other
1.53k stars 130 forks source link

cannot import enaml file if there is a python file with the same file name #410

Closed AndiEcker closed 4 years ago

AndiEcker commented 4 years ago

Having a project with the files main.py and main.enaml or a extension package with the files names package_folder/extension.enaml and package_folder/extension.py, there is currently no way to import the enaml file.

With the few changes of PR #409 this would be possible.

And we should gain performance because (a) there is no longer any need to reverse the list of importers and (b) the remove of the reporters from sys.meta_path (on context exit) should also be faster because the items to remove are at the top of the sys.meta_path.

frmdstryr commented 4 years ago

What is import main from any other enaml file supposed to do when they both have the same module name?

I think it's better to just not use two modules with the same name.

MatthieuDartiailh commented 4 years ago

I agree with @frmdstryr. Having different behavior in python and in enaml file is likely to create weird situations and the gain seems small to me (having written large enaml apps).

An opinion @sccolbert ?

sccolbert commented 4 years ago

I’m -1 on this for the aforementioned reasons. Its also a needlessly breaking change.

Chris On Apr 9, 2020, 12:42 -0500, Matthieu Dartiailh notifications@github.com, wrote:

I agree with @frmdstryr. Having different behavior in python and in enaml file is likely to create weird situations and the gain seems small to me (having written large enaml apps). An opinion @sccolbert ? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

AndiEcker commented 4 years ago

Thanks to all of you for your input and thoughts!!

Following your recommendations I will close this issue/PR. Closes #409, closes #410.

FYI: Just noticed that it is only working for local enaml/py modules. The other mentioned use case for packages is not working with the PR: trying to import within the enaml.imports() context the package/module.enaml will actually try to import the python module package/module.py.