PluginManager also scans user site packages

In case the user site packages are not yet part of the used
working set OR the sys path and ENABLE_USER_SITE is true, the
manager will now make sure that the folder is searched for plugins
as well upon plugin reload.

This is necessary since Python will not automatically include the
user site directory upon firing up the program in case there's
nothing installed to it/it doesn't exist. If a plugin is installed
during run time with --user that will lead to it not being found,
which is undesirable. Hence run time manipulation of sys.path and
the workingset becomes necessary.
This commit is contained in:
Gina Häußge 2015-09-30 13:30:39 +02:00
parent 10db8c9577
commit fbfac4b569

View file

@ -562,9 +562,18 @@ class PluginManager(object):
def _find_plugins_from_entry_points(self, groups, existing, ignore_uninstalled=True):
result = dict()
# let's make sure we have a current working set
# let's make sure we have a current working set ...
working_set = pkg_resources.WorkingSet()
# ... including the user's site packages
import site
import sys
if site.ENABLE_USER_SITE:
if not site.USER_SITE in working_set.entries:
working_set.add_entry(site.USER_SITE)
if not site.USER_SITE in sys.path:
site.addsitedir(site.USER_SITE)
if not isinstance(groups, (list, tuple)):
groups = [groups]