Skip to content

Commit

Permalink
fix: use --prefix instead of --user for pip install commands
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Aug 27, 2024
1 parent c9a4611 commit 670a51f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
13 changes: 7 additions & 6 deletions python/src/endstone/_internal/bootstrap/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 5 additions & 3 deletions python/src/endstone/_internal/plugin_loader.py
Original file line number Diff line number Diff line change
@@ -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"]

Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 670a51f

Please sign in to comment.