Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

2.3 KB
Raw Blame
from __future__ import annotations

import tomllib
from pathlib import Path


PROJECT_ROOT = Path(__file__).resolve().parents[2]

CLIENT_SHARED_DTO_DEPENDENCIES = {
    "httpx==0.28.1",
    "httpx2>=2.5.0,<3.0.0",
    "pydantic>=2.12.5,<2.13",
    "pydantic-ai-harness>=0.20.0,<0.21.0",
    "pydantic-ai-slim==2.53.0",
    "typing-extensions>=4.12.2,<5.0.0",
}

SERVER_RUNTIME_DEPENDENCIES = {
    "e2b>=2.55.1,<3.0.0",
    "fastapi==0.136.0",
    "graphon==0.8.0",
    "grpcio>=1.60.0,<2.0.0",
    "jsonschema>=4.23.0,<5.0.0",
    "jwcrypto>=1.5.6,<2",
    "logfire[fastapi,httpx,redis]>=4.37.0,<5.0.0",
    "openshell>=0.0.106,<0.1.0",
    "pillow>=13.0.0,<14",
    "pydantic-ai-slim[anthropic,google,openai]==2.53.0",
    "pydantic-settings>=2.12.0,<3.0.0",
    "redis>=7.4.0,<8.0.0",
    "uvicorn[standard]==0.46.0",
}

DEV_DEPENDENCIES = {
    "coverage[toml]>=7.10.7",
    "fakeredis[lua]>=2.31.0",
    "pyrefly>=1.2.0",
    "pytest>=9.0.3",
    "pytest-examples>=0.0.18",
    "pytest-mock>=3.14.0",
    "ruff>=0.15.11",
}


def _read_pyproject():
    return tomllib.loads((PROJECT_ROOT / "pyproject.toml").read_text(encoding="utf-8"))


def test_project_dependencies_split_client_and_server_requirements() -> None:
    pyproject = _read_pyproject()
    project = pyproject["project"]

    assert set(project["dependencies"]) == CLIENT_SHARED_DTO_DEPENDENCIES
    assert set(project["optional-dependencies"]["server"]) == SERVER_RUNTIME_DEPENDENCIES
    assert set(pyproject["dependency-groups"]["dev"]) == DEV_DEPENDENCIES


def test_default_package_discovery_excludes_example_packages() -> None:
    pyproject = _read_pyproject()
    find_config = pyproject["tool"]["setuptools"]["packages"]["find"]

    assert find_config["where"] == ["src"]
    assert "shellctl*" in find_config["include"]
    assert "shellctl_runtime*" not in find_config["include"]
    assert "agenton_examples*" not in find_config["include"]
    assert "dify_agent_examples*" not in find_config["include"]


def test_project_declares_console_scripts() -> None:
    pyproject = _read_pyproject()
    scripts = pyproject["project"]["scripts"]

    assert scripts["dify-agent-stub-server"] == "dify_agent.agent_stub.server.cli:main"
    assert "dify-agent" not in scripts
    assert "shellctl" not in scripts
    assert "shellctl-sanitize-pty" not in scripts
    assert "shellctl-runner-exit" not in scripts