python312Packages.{langgraph,langgraph-prebuilt}: unbundle prebuilt, update both

This commit is contained in:
Sarah Clark
2025-04-05 09:53:21 -07:00
parent 09ba7e257a
commit d27ed9aaea
3 changed files with 111 additions and 66 deletions
@@ -0,0 +1,104 @@
{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
# build-system
poetry-core,
# dependencies
langchain-core,
langgraph-checkpoint,
# tests
langgraph-checkpoint-postgres,
langgraph-checkpoint-sqlite,
postgresql,
postgresqlTestHook,
psycopg-pool,
psycopg,
pytest-asyncio,
pytest-mock,
pytestCheckHook,
# passthru
nix-update-script,
}:
# langgraph-prebuilt isn't meant to be a standalone package but is bundled into langgraph at build time.
# It exists so the langgraph team can iterate on it without having to rebuild langgraph.
buildPythonPackage rec {
pname = "langgraph-prebuilt";
version = "0.1.8";
pyproject = true;
src = fetchFromGitHub {
owner = "langchain-ai";
repo = "langgraph";
tag = "prebuilt==${version}";
hash = "sha256-mYcj7HRbB5H6G0CVLOICKgdtR5Wlv9WeTIBjQJqlhOE=";
};
sourceRoot = "${src.name}/libs/prebuilt";
build-system = [ poetry-core ];
dependencies = [
langchain-core
langgraph-checkpoint
];
skipPythonImportsCheck = true; # This will be packaged with langgraph
# postgresql doesn't play nicely with the darwin sandbox:
# FATAL: could not create shared memory segment: Operation not permitted
doCheck = !stdenv.hostPlatform.isDarwin;
nativeCheckInputs = [
pytestCheckHook
postgresql
postgresqlTestHook
];
checkInputs = [
langgraph-checkpoint
langgraph-checkpoint-postgres
langgraph-checkpoint-sqlite
psycopg
psycopg-pool
pytest-asyncio
pytest-mock
];
preCheck = ''
export PYTHONPATH=${src}/libs/langgraph:$PYTHONPATH
'';
pytestFlagsArray = [
"-W"
"ignore::pytest.PytestDeprecationWarning"
"-W"
"ignore::DeprecationWarning"
];
disabledTestPaths = [
# psycopg.OperationalError: connection failed: connection to server at "127.0.0.1", port 5442 failed: Connection refused
# Is the server running on that host and accepting TCP/IP connections?
"tests/test_react_agent.py"
];
passthru.updateScript = nix-update-script {
extraArgs = [
"--version-regex"
"prebuilt==(\\d+\\.\\d+\\.\\d+)"
];
};
meta = {
description = "Prebuilt agents add-on for Langgraph. Should always be bundled with langgraph";
homepage = "https://github.com/langchain-ai/langgraph";
changelog = "https://github.com/langchain-ai/langgraph/releases/tag/${version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ sarahec ];
};
}
@@ -10,7 +10,9 @@
# dependencies
langchain-core,
langgraph-checkpoint,
langgraph-prebuilt,
langgraph-sdk,
xxhash,
# tests
aiosqlite,
@@ -33,80 +35,16 @@
postgresql,
postgresqlTestHook,
}:
let
# langgraph-prebuilt isn't meant to be a standalone package but is bundled into langgraph at build time.
# It exists so the langgraph team can iterate on it without having to rebuild langgraph.
langgraph-prebuilt = buildPythonPackage rec {
pname = "langgraph-prebuilt";
version = "0.1.1";
pyproject = true;
src = fetchFromGitHub {
owner = "langchain-ai";
repo = "langgraph";
tag = "prebuilt==${version}";
hash = "sha256-Kyyr4BSrUReC6jBp4LItuS/JNSzGK5IUaPl7UaLse78=";
};
sourceRoot = "${src.name}/libs/prebuilt";
build-system = [ poetry-core ];
dependencies = [
langchain-core
langgraph-checkpoint
];
skipPythonImportsCheck = true; # This will be packaged with langgraph
# postgresql doesn't play nicely with the darwin sandbox:
# FATAL: could not create shared memory segment: Operation not permitted
doCheck = !stdenv.hostPlatform.isDarwin;
nativeCheckInputs = [
pytestCheckHook
postgresql
postgresqlTestHook
];
checkInputs = [
langgraph-checkpoint
langgraph-checkpoint-postgres
langgraph-checkpoint-sqlite
psycopg
psycopg-pool
pytest-asyncio
pytest-mock
];
preCheck = ''
export PYTHONPATH=${src}/libs/langgraph:$PYTHONPATH
'';
pytestFlagsArray = [
"-W"
"ignore::pytest.PytestDeprecationWarning"
"-W"
"ignore::DeprecationWarning"
];
disabledTestPaths = [
# psycopg.OperationalError: connection failed: connection to server at "127.0.0.1", port 5442 failed: Connection refused
# Is the server running on that host and accepting TCP/IP connections?
"tests/test_react_agent.py"
];
};
in
buildPythonPackage rec {
pname = "langgraph";
version = "0.3.2";
version = "0.3.24";
pyproject = true;
src = fetchFromGitHub {
owner = "langchain-ai";
repo = "langgraph";
tag = "${version}";
hash = "sha256-EawVIzG+db2k6/tQyUHCF6SzlO77QTXsYRUm3XpLu/c=";
hash = "sha256-NlTpBXBeADlIHQDlt0muJEuoKOgXiAtAo8GoU5CsvZo=";
};
postgresqlTestSetupPost = ''
@@ -123,6 +61,7 @@ buildPythonPackage rec {
langgraph-checkpoint
langgraph-prebuilt
langgraph-sdk
xxhash
];
pythonImportsCheck = [ "langgraph" ];
+2
View File
@@ -7464,6 +7464,8 @@ self: super: with self; {
langgraph-cli = callPackage ../development/python-modules/langgraph-cli { };
langgraph-prebuilt = callPackage ../development/python-modules/langgraph-prebuilt { };
langgraph-sdk = callPackage ../development/python-modules/langgraph-sdk { };
langid = callPackage ../development/python-modules/langid { };