fix: reduce end-user installation footprint
This commit is contained in:
@@ -13,7 +13,7 @@ from .common import (
|
||||
shutil,
|
||||
subprocess,
|
||||
)
|
||||
from .project import inspect_project
|
||||
from .project import _venv_python_path, inspect_project
|
||||
|
||||
|
||||
def doctor_project(
|
||||
@@ -47,10 +47,7 @@ def doctor_project(
|
||||
commands = (
|
||||
[uv_bin, "lock", "--check"],
|
||||
[
|
||||
uv_bin,
|
||||
"run",
|
||||
"--no-sync",
|
||||
"python",
|
||||
str(_venv_python_path(root)),
|
||||
"-c",
|
||||
"import mcp; import nocobase_crm_mcp",
|
||||
],
|
||||
|
||||
@@ -101,9 +101,19 @@ def prepare_project(
|
||||
shutil.copy2(example_path, config_path)
|
||||
created_config = True
|
||||
|
||||
command = [uv_bin, "sync", "--locked", "--python", f"{MIN_PYTHON[0]}.{MIN_PYTHON[1]}"]
|
||||
venv_path = root / ".venv"
|
||||
command = [uv_bin, "sync", "--locked", "--no-dev", "--python", f"{MIN_PYTHON[0]}.{MIN_PYTHON[1]}"]
|
||||
command_environment = os.environ.copy()
|
||||
command_environment["UV_PROJECT_ENVIRONMENT"] = str(venv_path)
|
||||
try:
|
||||
result = runner(command, cwd=str(root), capture_output=True, text=True, check=False)
|
||||
result = runner(
|
||||
command,
|
||||
cwd=str(root),
|
||||
env=command_environment,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
except OSError as error:
|
||||
raise InstallerError(f"Could not execute uv sync: {error}") from error
|
||||
if result.returncode != 0:
|
||||
@@ -116,7 +126,8 @@ def prepare_project(
|
||||
"projectRoot": str(root),
|
||||
"configPath": str(config_path),
|
||||
"configCreated": created_config,
|
||||
"dependencies": "locked",
|
||||
"dependencies": "locked-runtime-only",
|
||||
"environmentPath": str(venv_path),
|
||||
}
|
||||
|
||||
|
||||
@@ -169,20 +180,16 @@ def render_client_config(
|
||||
*,
|
||||
enable_writes: bool = False,
|
||||
which: Which = shutil.which,
|
||||
os_name: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
root = _project_root(project_root)
|
||||
uv_bin = which("uv") or "uv"
|
||||
nb_bin = which("nb") or "nb"
|
||||
if os.path.isabs(uv_bin):
|
||||
uv_bin = os.path.abspath(uv_bin)
|
||||
if os.path.isabs(nb_bin):
|
||||
nb_bin = os.path.abspath(nb_bin)
|
||||
python_bin = _venv_python_path(root, os_name=os_name)
|
||||
args = [
|
||||
"--directory",
|
||||
str(root),
|
||||
"run",
|
||||
"--no-sync",
|
||||
"nocobase-crm-mcp",
|
||||
"-m",
|
||||
"nocobase_crm_mcp.server",
|
||||
"--config",
|
||||
str(root / "config.json"),
|
||||
]
|
||||
@@ -191,9 +198,15 @@ def render_client_config(
|
||||
return {
|
||||
"mcpServers": {
|
||||
SERVER_NAME: {
|
||||
"command": uv_bin,
|
||||
"command": str(python_bin),
|
||||
"args": args,
|
||||
"env": {"NOCOBASE_MCP_NB_BIN": nb_bin},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def _venv_python_path(root: Path, *, os_name: str | None = None) -> Path:
|
||||
if (os_name or os.name) == "nt":
|
||||
return root / ".venv" / "Scripts" / "python.exe"
|
||||
return root / ".venv" / "bin" / "python"
|
||||
|
||||
Reference in New Issue
Block a user