I have a module that I pack as an egg with setuptools. I have a problem with relative/absolute improts.
The directory structure is the following:
setup.py        # using setuptools
mymodule/
 |- __init__.py
 |- mymodule_core.py
 |- utils.py
When I easy_install mymodule in the system from egg, this import works well:
# mymodule_core.py
from mymodule.utils import some_functions
But I want also to run mymodule_core.py from the command line, without installing it (for short tests etc). In that case, the previous import would fail, and this works:
# mymodule_core.py
from utils import some_functions
How to handle the import so it would work in both cases?
I guess that the proper solution would include if __name__ == "__main__", from .. import something and __package__ = but I cannot make it work
Related:
 
     
    