Project

General

Profile

Actions

Bug #67

open

Python imports, absolute vs. relative

Added by Jim Pulokas almost 15 years ago. Updated about 11 years ago.

Status:
Assigned
Priority:
Low
Assignee:
Category:
-
Start date:
01/28/2010
Due date:
% Done:

30%

Estimated time:
Affected Version:
Appion/Leginon 2.0.1
Show in known bugs:
No
Workaround:

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.


Related issues 1 (0 open1 closed)

Related to Appion - Bug #42: Pyappion lib folder and import commandsClosed01/20/2010

Actions
Actions

Also available in: Atom PDF