diff --git a/python/src/endstone/_internal/bootstrap/base.py b/python/src/endstone/_internal/bootstrap/base.py index 02134fd0e..420db3342 100644 --- a/python/src/endstone/_internal/bootstrap/base.py +++ b/python/src/endstone/_internal/bootstrap/base.py @@ -4,17 +4,19 @@ import os import platform import shutil +import site import subprocess import sys +import tempfile import zipfile from pathlib import Path -import tempfile from typing import Union + import click import requests +from endstone import __minecraft_version__ as minecraft_version from packaging.version import Version from rich.progress import Progress, TextColumn, BarColumn, DownloadColumn, TimeRemainingColumn -from endstone import __minecraft_version__ as minecraft_version class Bootstrap: @@ -217,12 +219,11 @@ def _create_process(self, *args, **kwargs) -> None: **kwargs: Arbitrary keyword arguments. """ - user_base = str((self.plugin_path / ".local").resolve().absolute()) - shutil.rmtree(user_base, ignore_errors=True) + prefix = str((self.plugin_path / ".local").resolve().absolute()) + shutil.rmtree(prefix, ignore_errors=True) env = kwargs.pop("env", os.environ.copy()) - env["PYTHONUSERBASE"] = user_base - env["PATH"] = os.pathsep.join(sys.path) + env["PATH"] = os.pathsep.join(site.getsitepackages(prefixes=[prefix]) + sys.path) env["PYTHONPATH"] = os.pathsep.join(sys.path) env["PYTHONIOENCODING"] = "UTF-8" self._process = subprocess.Popen( diff --git a/python/src/endstone/_internal/plugin_loader.py b/python/src/endstone/_internal/plugin_loader.py index e7c483427..76f68e22e 100644 --- a/python/src/endstone/_internal/plugin_loader.py +++ b/python/src/endstone/_internal/plugin_loader.py @@ -1,16 +1,17 @@ import glob import importlib +import os import os.path import site -import os import subprocess import sys -from importlib_metadata import entry_points, metadata from typing import List + from endstone import Server from endstone.command import Command from endstone.permissions import Permission, PermissionDefault from endstone.plugin import PluginDescription, PluginLoader, Plugin, PluginLoadOrder +from importlib_metadata import entry_points, metadata __all__ = ["PythonPluginLoader"] @@ -81,7 +82,8 @@ def load_plugins(self, directory) -> List[Plugin]: "pip", "install", file, - "--user", + "--prefix", + os.path.join(directory, ".local"), "--quiet", "--no-warn-script-location", "--disable-pip-version-check",