#170 closed defect (fixed)
Plugin import problem when executing console scripts
Reported by: | dmartinc | Owned by: | dmartinc |
---|---|---|---|
Priority: | normal | Milestone: | v0.98.1 |
Component: | General | Version: | 0.97.0 |
Keywords: | Cc: |
Description
There are problems when executing code from the console (as opposed to code executed by mod-python) that involves dynamic importing of plugin modules.
The code that takes care of this task is in MaKaC/plugins/init.py .
For example, it seems that the path that the MaKaC/plugins/init.py believes it's in is different depending on where the execution came from (Apache or console). For Apache, it's an absolute path, but relative if coming from the console.
There are also other problems like importing a plugin not importing some of it's sub-modules...
These problems do not affect the working of plugins in Apache but give problems when executing Python unit tests that involve plugins.
Change History (5)
comment:1 Changed 6 years ago by pferreir
- Milestone set to v0.98
- Version changed from 0.97 to 0.98
comment:2 Changed 6 years ago by pferreir
- Version changed from 0.98 to 0.97
comment:3 Changed 6 years ago by dmartinc
- Status changed from new to accepted
comment:4 Changed 5 years ago by david.martin.clavo@…
- Resolution set to fixed
- Status changed from accepted to closed
commit c6b71074dc59d0e322b31716e47a2ac02eb42d3f
Author: David Martín Clavo <david.martin.clavo@…>
Date: Thu Mar 25 16:02:53 2010 +0100
[IMP] Fix and rework of low-level plugin system
-fixes #170
-The root of the problem was the use of
relative paths, relative imports, and
os.chdir() statements.
-Moved functionality from MaKaC.plugins.init.py
to MaKaC.plugins.pluginLoader.py
-Made system simpler and put lots of comments
-Plugin's init.py do not need to import and
declare useless stuff.
-Better exceptions during plugin import:
-Changed importName not to capture exceptions.
This way exceptions happen on problems instead
of these being ignored and having problems later on.
-Only captured ImportError? and KeyError? at points
where these can happen[IMP]
The problem lies with the fact that the plugin import mechanism does an os.chdir() before doing the imports, and that the first line executed by setup.py adds "indico" to the sys.path without turning "indico" in an absolute path.
So I will change both the plugin import mechanism to use abs paths (and do some other very needed refactoring) and change setup.py to add an abs path to sys.path.