python3Packages.gradio-client: tether version to gradio

This commit is contained in:
Peder Bergebakken Sundt
2026-03-08 19:51:56 +01:00
parent 380e22c413
commit 3e0ce62945
3 changed files with 31 additions and 23 deletions
@@ -2,8 +2,8 @@
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
gitUpdater,
nix-update-script,
jq,
# build-system
hatchling,
@@ -36,20 +36,8 @@ buildPythonPackage (finalAttrs: {
pyproject = true;
# no tests on pypi
src = fetchFromGitHub {
owner = "gradio-app";
repo = "gradio";
# not to be confused with @gradio/client@${version}
# tag = "gradio_client@${finalAttrs.version}";
# TODO: switch back to a tag next release, if they tag it.
rev = "8b03393a51e1e03fb04cb0a41b9a5dc3266a58aa"; # 2.2.0
sparseCheckout = [
"client/python"
"gradio/media_assets"
];
hash = "sha256-LkTZwPyHe1w8D5unEMW7dBGKNHxM7gWJ7I+4HwiexKk=";
};
# they've stopped tagging "gradio_client@.*" and "@gradio/client@.*" tags on github
inherit (gradio) src;
sourceRoot = "${finalAttrs.src.name}/client/python";
# Because we set sourceRoot above, the folders "client/python"
@@ -59,6 +47,20 @@ buildPythonPackage (finalAttrs: {
--replace-fail 'from client.python.test import media_data' 'import media_data'
'';
preConfigure = ''
# sanity check
if [[ "$(jq <gradio_client/package.json .version -r)" != "$version" ]]; then
echo >&2 "ERROR: version mismatch with package.json:"
echo >&2 "version = $version"
(set -x; cat >&2 gradio_client/package.json)
false
fi
'';
nativeBuildInputs = [
jq
];
build-system = [
hatchling
hatch-requirements-txt
@@ -118,16 +120,15 @@ buildPythonPackage (finalAttrs: {
__darwinAllowLocalNetworking = true;
passthru.updateScript = gitUpdater {
rev-prefix = "gradio_client@";
ignoredVersions = ".*-(beta|dev).*";
passthru = {
inherit (gradio) updateScript;
};
meta = {
description = "Lightweight library to use any Gradio app as an API";
homepage = "https://www.gradio.app/";
downloadPage = "https://github.com/gradio-app/gradio/tree/main/client/python";
# changelog = "https://github.com/gradio-app/gradio/releases/tag/${finalAttrs.src.tag}"; TODO: uncomment if the tag exists
changelog = "https://github.com/gradio-app/gradio/blob/${finalAttrs.src.tag}/client/python/gradio_client/CHANGELOG.md";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ pbsds ];
};
@@ -422,7 +422,9 @@ buildPythonPackage (finalAttrs: {
# enough tags for the ones we're looking for to show up.
updateScript = writeScript "update-python3Packages.gradio" ''
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p common-updater-scripts coreutils gnugrep gnused nix-update
#! nix-shell -i bash -p common-updater-scripts coreutils gnugrep gnused nix-update jq curl
set -euo pipefail
set -x
tag=$(list-git-tags \
| grep "^gradio@" \
@@ -432,7 +434,10 @@ buildPythonPackage (finalAttrs: {
| head -n 1 \
| tr -d '\n' \
)
nix-update --version="$tag"
nix-update python3Packages.gradio --version="$tag"
gradio_client_version="$(curl https://raw.githubusercontent.com/gradio-app/gradio/gradio@"$tag"/client/python/gradio_client/package.json | jq ".version" -r)"
nix-update python3Packages.gradio-client --version="$gradio_client_version" --no-src
'';
};
+3 -1
View File
@@ -6615,7 +6615,9 @@ self: super: with self; {
gradio = callPackage ../development/python-modules/gradio { };
gradio-client = callPackage ../development/python-modules/gradio/client.nix { };
gradio-client = callPackage ../development/python-modules/gradio/client.nix {
inherit (pkgs) jq;
};
gradio-pdf = callPackage ../development/python-modules/gradio-pdf { };