Ask user site packages from the backend
@@ -10,7 +10,7 @@ from logging import exception
from os import makedirs
from tkinter import messagebox, ttk
from tkinter.messagebox import showerror
-from typing import List, Union, Dict, Tuple
+from typing import List, Union, Dict, Tuple, cast
import thonny
from thonny import get_runner, get_workbench, running, tktextext, ui_utils
@@ -18,7 +18,7 @@ from thonny.common import InlineCommand, is_same_path, normpath_with_actual_case
from thonny.languages import tr
from thonny.plugins.cpython_frontend import CPythonProxy
from thonny.plugins.cpython_ssh import SshCPythonProxy
-from thonny.running import get_interpreter_for_subprocess, InlineCommandDialog
+from thonny.running import get_interpreter_for_subprocess, InlineCommandDialog, SubprocessProxy
from thonny.ui_utils import (
AutoScrollbar,
CommonDialog,
@@ -854,9 +854,7 @@ class PipDialog(CommonDialog):
else:
# readonly if not in a virtual environment
# and user site packages is disabled
- import site
-
- return not site.ENABLE_USER_SITE
+ return not cast(SubprocessProxy, get_runner().get_backend_proxy()).get_user_site_packages()
def _tweak_search_results(self, results, query):
return results
@@ -1091,18 +1089,6 @@ class PluginsPipDialog(PipDialog):
+ "\n"
)
- runner = get_runner()
- if (
- runner is not None
- and runner.get_local_executable() is not None
- and is_same_path(self._get_interpreter(), get_runner().get_local_executable())
- ):
- banner_msg += (
- tr(
- "(In this case Thonny's back-end uses same interpreter, so both dialogs manage same packages.)"
- )
- + "\n"
- )
banner_msg += "\n" + tr(
"NB! You need to restart Thonny after installing / upgrading / uninstalling a plug-in."
