python3Packages.langchain*: fix bulk update script

This commit is contained in:
Sarah Clark
2025-03-30 13:09:18 -07:00
parent 0a5d47a772
commit 1791347c19
4 changed files with 53 additions and 16 deletions
@@ -28,9 +28,6 @@
pytest-xdist,
pytestCheckHook,
syrupy,
# passthru
nix-update-script,
}:
buildPythonPackage rec {
@@ -95,11 +92,9 @@ buildPythonPackage rec {
doCheck = true;
});
updateScript = nix-update-script {
extraArgs = [
"--version-regex"
"^langchain-core==([0-9.]+)$"
];
updateScript = {
command = [./update.sh ];
supportedFeatures = [ "commit"];
};
};
+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts jq
set -euo pipefail
declare -ar packages=(
langchain
langchain-azure-dynamic-sessions
langchain-chroma
langchain-community
langchain-core
langchain-groq
langchain-huggingface
langchain-mongodb
langchain-ollama
langchain-openai
langchain-tests
langchain-text-splitters
)
tags=$(git ls-remote --tags --refs "https://github.com/langchain-ai/langchain" | cut --delimiter=/ --field=3-)
# Will be printed as JSON at the end to list what needs updating
updates=""
for package in ${packages[@]}
do
pyPackage="python3Packages.$package"
oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion $pyPackage" | tr -d '"')"
newVersion=$(echo "$tags" | grep -Po "(?<=$package==)\d+\.\d+\.\d+$" | sort --version-sort --reverse | head -1 )
if [[ "$newVersion" != "$oldVersion" ]]; then
update-source-version $pyPackage "$newVersion"
updates+="{
\"attrPath\": \"$pyPackage\",
\"oldVersion\": \"$oldVersion\",
\"newVersion\": \"$newVersion\",
\"files\": [
\"$PWD/pkgs/development/python-modules/${package}/default.nix\"
]
},"
fi
done
# Remove trailing comma
updates=${updates%,}
# Print the updates in JSON format
echo "[ $updates ]"
@@ -2,7 +2,6 @@
lib,
buildPythonPackage,
fetchFromGitHub,
nix-update-script,
# build-system
pdm-backend,
@@ -62,11 +61,8 @@ buildPythonPackage rec {
pytestCheckHook
];
passthru.updateScript = nix-update-script {
extraArgs = [
"--version-regex"
"^langchain-tests==([0-9.]+)$"
];
passthru = {
inherit (langchain-core) updateScript;
};
meta = {
@@ -41,14 +41,14 @@
buildPythonPackage rec {
pname = "langchain";
version = "0.3.20";
version = "0.3.21";
pyproject = true;
src = fetchFromGitHub {
owner = "langchain-ai";
repo = "langchain";
tag = "langchain==${version}";
hash = "sha256-N209wUGdlHkOZynhSSE+ZHylL7cK+8H3PfZIG/wvMd0=";
hash = "sha256-Up/pH2TxLPiPO49oIa2ZlNeH3TyN9sZSlNsqOIRmlxc=";
};
sourceRoot = "${src.name}/libs/langchain";