[Distutils] installing .py plugins to an alternate directory

P.J. Eby pje at telecommunity.com
Sat Dec 5 05:30:35 CET 2009

At 01:18 AM 12/5/2009 +0100, Andrew Dalke wrote:
>It appears that pkg_resources does some caching, including using 
>linecache. I can't tell how well it would work if our pluging 
>packages were updated after the main server was running.

If you need to ensure that you get a fresh list of plugins each time, 
you can use "for entry_point in 
pkg_resources.WorkingSet().iter_entry_points(...)".  Or more 
precisely, you can create a new WorkingSet() whenever you want to 
start over with a clean cache.

(Btw, the only thing pkg_resources uses linecache for is to ensure 
that the source of a script loaded from an alternate location is 
viewable in linecache as though it came from the location the script 
was run from.  This is a debugging aid only, and doesn't have any 
effect on anything that's not trying to dump out source code lines 
(such as an error reporting tool, or the Python debugger).)

More information about the Distutils-SIG mailing list