Keep modified PYTHONUSERBASE in frontend env
@@ -4,6 +4,7 @@ import sys
THONNY_USER_DIR = os.environ.get("THONNY_USER_DIR",
os.path.expanduser(os.path.join("~", ".thonny")))
+# Thonny will use different directory for user packages
THONNY_USER_BASE = os.path.join(THONNY_USER_DIR, "plugins")
def launch():
@@ -49,7 +50,6 @@ def launch():
tkinter.messagebox.showerror("Internal error", traceback.format_exc())
return -1
finally:
- from thonny import get_runner
runner = get_runner()
if runner != None:
runner.destroy_backend()
@@ -84,18 +84,18 @@ def _prepare_thonny_user_dir():
def _update_sys_path():
import site
+ # Thonny will use different directory for user packages
# remove old dir from path
if site.getusersitepackages() in sys.path:
sys.path.remove(site.getusersitepackages())
- # compute usersitepackages that plugins installation subprocess would see
+ # compute new usersitepackages
import subprocess
- env = os.environ.copy()
- env["PYTHONUSERBASE"] = THONNY_USER_BASE
+ os.environ["PYTHONUSERBASE"] = THONNY_USER_BASE
proc = subprocess.Popen(
- [sys.executable.replace("thonny.exe", "pythonw.exe"),
+ [sys.executable.replace("thonny.exe", "pythonw.exe").replace("python.exe", "pythonw.exe"),
"-c", "import site; print(site.getusersitepackages())"],
- universal_newlines=True, env=env, stdout=subprocess.PIPE)
+ universal_newlines=True, stdout=subprocess.PIPE)
plugins_sitepackages = proc.stdout.readline().strip()
sys.path.append(plugins_sitepackages)
