1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 poetry-core,
9
10 # dependencies
11 langchain-core,
12 langgraph-checkpoint,
13 langgraph-sdk,
14
15 # tests
16 aiosqlite,
17 dataclasses-json,
18 grandalf,
19 httpx,
20 langgraph-checkpoint-duckdb,
21 langgraph-checkpoint-postgres,
22 langgraph-checkpoint-sqlite,
23 langsmith,
24 psycopg,
25 pydantic,
26 pytest-asyncio,
27 pytest-mock,
28 pytest-repeat,
29 pytest-xdist,
30 pytestCheckHook,
31 syrupy,
32 postgresql,
33 postgresqlTestHook,
34}:
35
36buildPythonPackage rec {
37 pname = "langgraph";
38 version = "0.2.56";
39 pyproject = true;
40
41 src = fetchFromGitHub {
42 owner = "langchain-ai";
43 repo = "langgraph";
44 tag = version;
45 hash = "sha256-X/IMNEmggu9bSJFUaTohbFYxGZBguf+eFb3ObmQGplk=";
46 };
47
48 postgresqlTestSetupPost = ''
49 substituteInPlace tests/conftest.py \
50 --replace-fail "DEFAULT_POSTGRES_URI = \"postgres://postgres:postgres@localhost:5442/\"" "DEFAULT_POSTGRES_URI = \"postgres:///$PGDATABASE\""
51 '';
52
53 sourceRoot = "${src.name}/libs/langgraph";
54
55 build-system = [ poetry-core ];
56
57 dependencies = [
58 langchain-core
59 langgraph-checkpoint
60 langgraph-sdk
61 ];
62
63 pythonImportsCheck = [ "langgraph" ];
64
65 # postgresql doesn't play nicely with the darwin sandbox:
66 # FATAL: could not create shared memory segment: Operation not permitted
67 doCheck = !stdenv.hostPlatform.isDarwin;
68
69 nativeCheckInputs = [
70 aiosqlite
71 dataclasses-json
72 grandalf
73 httpx
74 langgraph-checkpoint-duckdb
75 langgraph-checkpoint-postgres
76 langgraph-checkpoint-sqlite
77 langsmith
78 psycopg
79 psycopg.pool
80 pydantic
81 pytest-asyncio
82 pytest-mock
83 pytest-repeat
84 pytest-xdist
85 pytestCheckHook
86 syrupy
87 postgresql
88 postgresqlTestHook
89 ];
90
91 disabledTests = [
92 # test is flaky due to pydantic error on the exception
93 "test_doesnt_warn_valid_schema"
94 "test_tool_node_inject_store"
95
96 # Disabling tests that requires to create new random databases
97 "test_cancel_graph_astream"
98 "test_cancel_graph_astream_events_v2"
99 "test_channel_values"
100 "test_fork_always_re_runs_nodes"
101 "test_interruption_without_state_updates"
102 "test_interruption_without_state_updates_async"
103 "test_invoke_two_processes_in_out_interrupt"
104 "test_nested_graph_interrupts"
105 "test_no_modifier_async"
106 "test_no_modifier"
107 "test_pending_writes_resume"
108 "test_remove_message_via_state_update"
109 ];
110
111 disabledTestPaths = [
112 # psycopg.errors.InsufficientPrivilege: permission denied to create database
113 "tests/test_pregel_async.py"
114 "tests/test_pregel.py"
115 ];
116
117 passthru.updateScript = langgraph-sdk.updateScript;
118
119 meta = {
120 description = "Build resilient language agents as graphs";
121 homepage = "https://github.com/langchain-ai/langgraph";
122 changelog = "https://github.com/langchain-ai/langgraph/releases/tag/${version}";
123 license = lib.licenses.mit;
124 maintainers = with lib.maintainers; [ sarahec ];
125 };
126}