Bug #67
openPython imports, absolute vs. relative
30%
Description
We should be using absolute imports instead of relative imports when possible. This means for instance:
import leginon.leginondata
rather than
import leginondata
There are a few reasons why explained in PEP 328
Python 3 will require either absolute imports or relative imports using a new syntax. This means that absolute imports will be the best way to have something that works now with Python 2 and in the future with Python 3. It is also a bad idea to customize PYTHONPATH or add path modifiers like Leginon.pth as a shortcut to not using absolute paths. In all cases, there is risk of conflicting module names between different packages.
There are a few parts to resolving this in myami:
- Change import statements throughout myami to absolute module names. I think it should be OK to leave alone relative imports if it is a module importing another module in the exact same directory, but this will require syntax revision for Python 3. Scripts in appion/bin should use "import appionlib.xxxxx"
- Other references to module names in myami should start using absolute module names. For instance, the field names in the database like "REF|leginondata|AcquisitionImageData|image".
sinedon.cfg contains just a simple module name rather than absolute name. Noderegistry in Leginon had relative modules, but that has been fixed.