at master 3.7 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 7 # build-system 8 hatchling, 9 10 # dependencies 11 langchain-core, 12 langgraph-checkpoint, 13 langgraph-prebuilt, 14 langgraph-sdk, 15 pydantic, 16 xxhash, 17 18 # tests 19 aiosqlite, 20 dataclasses-json, 21 fakeredis, 22 grandalf, 23 httpx, 24 langgraph-checkpoint-postgres, 25 langgraph-checkpoint-sqlite, 26 langsmith, 27 psycopg, 28 pytest-asyncio, 29 pytest-mock, 30 pytest-repeat, 31 pytest-xdist, 32 pytestCheckHook, 33 syrupy, 34 postgresql, 35 postgresqlTestHook, 36 redisTestHook, 37 38 # passthru 39 nix-update-script, 40}: 41buildPythonPackage rec { 42 pname = "langgraph"; 43 version = "0.6.4"; 44 pyproject = true; 45 46 src = fetchFromGitHub { 47 owner = "langchain-ai"; 48 repo = "langgraph"; 49 tag = version; 50 hash = "sha256-9jl16cKp3E7j79PXrr/3splrcJtfQQN7yFJ5sfa6c+I="; 51 }; 52 53 postgresqlTestSetupPost = '' 54 substituteInPlace tests/conftest_store.py \ 55 --replace-fail "DEFAULT_POSTGRES_URI = \"postgres://postgres:postgres@localhost:5442/\"" "DEFAULT_POSTGRES_URI = \"postgres:///$PGDATABASE\"" 56 substituteInPlace tests/conftest_checkpointer.py \ 57 --replace-fail "DEFAULT_POSTGRES_URI = \"postgres://postgres:postgres@localhost:5442/\"" "DEFAULT_POSTGRES_URI = \"postgres:///$PGDATABASE\"" 58 ''; 59 60 sourceRoot = "${src.name}/libs/langgraph"; 61 62 build-system = [ hatchling ]; 63 64 dependencies = [ 65 langchain-core 66 langgraph-checkpoint 67 langgraph-prebuilt 68 langgraph-sdk 69 pydantic 70 xxhash 71 ]; 72 73 pythonImportsCheck = [ "langgraph" ]; 74 75 # postgresql doesn't play nicely with the darwin sandbox: 76 # FATAL: could not create shared memory segment: Operation not permitted 77 doCheck = !stdenv.hostPlatform.isDarwin; 78 79 nativeCheckInputs = [ 80 pytestCheckHook 81 postgresql 82 postgresqlTestHook 83 redisTestHook 84 fakeredis 85 langgraph-checkpoint 86 ]; 87 88 checkInputs = [ 89 aiosqlite 90 dataclasses-json 91 grandalf 92 httpx 93 langgraph-checkpoint-postgres 94 langgraph-checkpoint-sqlite 95 langsmith 96 psycopg 97 psycopg.pool 98 pydantic 99 pytest-asyncio 100 pytest-mock 101 pytest-repeat 102 pytest-xdist 103 syrupy 104 ]; 105 106 disabledTests = [ 107 # Requires `langgraph dev` to be running 108 "test_remote_graph_basic_invoke" 109 "test_remote_graph_stream_messages_tuple" 110 111 # Disabling tests that requires to create new random databases 112 "test_cancel_graph_astream" 113 "test_cancel_graph_astream_events_v2" 114 "test_channel_values" 115 "test_fork_always_re_runs_nodes" 116 "test_interruption_without_state_updates" 117 "test_interruption_without_state_updates_async" 118 "test_invoke_two_processes_in_out_interrupt" 119 "test_nested_graph_interrupts" 120 "test_no_modifier_async" 121 "test_no_modifier" 122 "test_pending_writes_resume" 123 "test_remove_message_via_state_update" 124 ]; 125 126 disabledTestPaths = [ 127 # psycopg.errors.InsufficientPrivilege: permission denied to create database 128 "tests/test_checkpoint_migration.py" 129 "tests/test_large_cases.py" 130 "tests/test_large_cases_async.py" 131 "tests/test_pregel.py" 132 "tests/test_pregel_async.py" 133 ]; 134 135 # Since `langgraph` is the only unprefixed package, we have to use an explicit match 136 passthru = { 137 # python updater script sets the wrong tag 138 skipBulkUpdate = true; 139 updateScript = nix-update-script { 140 extraArgs = [ 141 "--version-regex" 142 "([0-9.]+)" 143 ]; 144 }; 145 }; 146 147 meta = { 148 description = "Build resilient language agents as graphs"; 149 homepage = "https://github.com/langchain-ai/langgraph"; 150 changelog = "https://github.com/langchain-ai/langgraph/releases/tag/${src.tag}"; 151 license = lib.licenses.mit; 152 maintainers = with lib.maintainers; [ sarahec ]; 153 }; 154}