From fbfac4b569ab1e31750d225fc007717cb85334d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 30 Sep 2015 13:30:39 +0200 Subject: [PATCH] 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. --- src/octoprint/plugin/core.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index 6f9d9c63..41a36883 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -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]