Quantcast

plugin manager reload doesn't work in trunk

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

plugin manager reload doesn't work in trunk

Tim Lyons
Administrator
In revision 20481, the following change was made:

GEP 026: replace make
* somewhere along the road, all of plugins dir was added to sys.path,  
this is not ok, we only needed lib on sys.path
* As due to the GEP we can import from the plugin directory, better  
just import the lib modules needed, and avoid sys.path extension
* At the same time this fixes a bug due to __init__.py being present,  
import of a file named equal to the plugin directory was importing the  
__init__.py, not the intended file.

The effect of this is that reload no longer works. In plug/
_manager.py, reload_plugins calls self.reload. reload fails because  
the module is not found. self.import_plugin imports the module again,  
which executes the module, but this is still the original module, not  
the module as changed.

As described here: http://docs.python.org/3.2/library/imp.html 
(imp.reload(module)) "This is useful if you have edited the module  
source file using an external editor and want to try out the new  
version without leaving the Python interpreter."

Note this is for modules that had successfully loaded the first time.  
I don't know what the effect is for modules that had failed on load  
before. Note also that "print(traceback.print_exc()) " doesn't work,  
it should either be format_exc or without the surrounding print().



I would have changed it myself, but seeing the comment "all of plugins  
dir was added to sys.path, this is not ok" - I don't know why "this is  
not OK", nor do I understand the significance of the second bullet  
above, so don't feel I can change it.

Please could someone fix this?

Thanks.

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: plugin manager reload doesn't work in trunk

Benny Malengier



2012/12/5 Tim Lyons <[hidden email]>
In revision 20481, the following change was made:

GEP 026: replace make
* somewhere along the road, all of plugins dir was added to sys.path,
this is not ok, we only needed lib on sys.path
* As due to the GEP we can import from the plugin directory, better
just import the lib modules needed, and avoid sys.path extension
* At the same time this fixes a bug due to __init__.py being present,
import of a file named equal to the plugin directory was importing the
__init__.py, not the intended file.

The effect of this is that reload no longer works. In plug/
_manager.py, reload_plugins calls self.reload. reload fails because
the module is not found. self.import_plugin imports the module again,
which executes the module, but this is still the original module, not
the module as changed.

As described here: http://docs.python.org/3.2/library/imp.html
(imp.reload(module)) "This is useful if you have edited the module
source file using an external editor and want to try out the new
version without leaving the Python interpreter."

Ok, we should use this then

Note this is for modules that had successfully loaded the first time.
I don't know what the effect is for modules that had failed on load
before. Note also that "print(traceback.print_exc()) " doesn't work,
it should either be format_exc or without the surrounding print().


Ok, if you don't change this, can you put it in a bug on the roadmap?


I would have changed it myself, but seeing the comment "all of plugins
dir was added to sys.path, this is not ok" - I don't know why "this is
not OK", nor do I understand the significance of the second bullet
above, so don't feel I can change it.

All plugin dir was on sys.path, so one could do in a  plugin: import sibling, with sibling.py somewhere in the plugin dir. As everything was on sys.path, collisions could occur. As the plugins directory is a known path in gramps, absolute import should be used, so from gramps.plugins..... import ....
This last is possible because we added __init__.py to have setup.py type of install working.

Is this clear.

Please could someone fix this?

Me not at the moment. Time again after 15.12. So if you don't do it, put it on the roadmap.
It is a bit unfortunate all old bugs have accumelated on the 4.0 roadmap...

Benny

Thanks.

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: plugin manager reload doesn't work in trunk

Tim Lyons
Administrator

On 5 Dec 2012, at 19:35, Benny Malengier wrote:




2012/12/5 Tim Lyons <[hidden email]>
In revision 20481, the following change was made:

GEP 026: replace make
* somewhere along the road, all of plugins dir was added to sys.path,
this is not ok, we only needed lib on sys.path
* As due to the GEP we can import from the plugin directory, better
just import the lib modules needed, and avoid sys.path extension
* At the same time this fixes a bug due to __init__.py being present,
import of a file named equal to the plugin directory was importing the
__init__.py, not the intended file.

The effect of this is that reload no longer works. In plug/
_manager.py, reload_plugins calls self.reload. reload fails because
the module is not found. self.import_plugin imports the module again,
which executes the module, but this is still the original module, not
the module as changed.

As described here: http://docs.python.org/3.2/library/imp.html
(imp.reload(module)) "This is useful if you have edited the module
source file using an external editor and want to try out the new
version without leaving the Python interpreter."

Ok, we should use this then

Note this is for modules that had successfully loaded the first time.
I don't know what the effect is for modules that had failed on load
before. Note also that "print(traceback.print_exc()) " doesn't work,
it should either be format_exc or without the surrounding print().


Ok, if you don't change this, can you put it in a bug on the roadmap?


I would have changed it myself, but seeing the comment "all of plugins
dir was added to sys.path, this is not ok" - I don't know why "this is
not OK", nor do I understand the significance of the second bullet
above, so don't feel I can change it.

All plugin dir was on sys.path, so one could do in a  plugin: import sibling, with sibling.py somewhere in the plugin dir. As everything was on sys.path, collisions could occur. As the plugins directory is a known path in gramps, absolute import should be used, so from gramps.plugins..... import ....
This last is possible because we added __init__.py to have setup.py type of install working.

Is this clear.

Please could someone fix this?

Me not at the moment. Time again after 15.12. So if you don't do it, put it on the roadmap.
It is a bit unfortunate all old bugs have accumelated on the 4.0 roadmap...


OK. I have raised bug 0006223: plugin manager reload doesn't work in trunk.

I have applied a fix at rev 20774 to at least get it to work, but it would be good for someone more familiar with the code to review this, as well as potentially to rationalise the code as suggested in the Additional Information in the bug.

(Just leaving the path to accumulate in sys.path does not work, presumably because the wrong plugins are found because of collisions).


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Loading...