diff --git a/doc/release-notes/rl-2605.section.md b/doc/release-notes/rl-2605.section.md index 144f8a55ca72..3a3977ffb779 100644 --- a/doc/release-notes/rl-2605.section.md +++ b/doc/release-notes/rl-2605.section.md @@ -20,6 +20,8 @@ - `iroh` has been removed and split up into `iroh-dns-server` and `iroh-relay`. +- `python3Packages.gradio` has been updated to version 6. See upstream's migration guide at https://www.gradio.app/main/guides/gradio-6-migration-guide. + - All Log4Shell vulnerability scanners were removed, as they were all unmaintained upstream and are no longer relevant given that the vulnerability has been fixed upstream for several years. - `asio` (standalone version of `boost::asio`) has been updated from 1.24.0 to 1.36.0. Some breaking changes were introduced between these diff --git a/pkgs/development/python-modules/gradio-pdf/default.nix b/pkgs/development/python-modules/gradio-pdf/default.nix index 1b86c84fbef3..26e990d0d275 100644 --- a/pkgs/development/python-modules/gradio-pdf/default.nix +++ b/pkgs/development/python-modules/gradio-pdf/default.nix @@ -11,7 +11,7 @@ buildPythonPackage { pname = "gradio-pdf"; - version = "0.0.22"; + version = "0.0.23"; pyproject = true; src = fetchFromGitHub { @@ -19,8 +19,8 @@ buildPythonPackage { repo = "gradio-pdf"; # No source release on Pypi # No tags on GitHub - rev = "8833e9cd419d2a5eeff98e3ae8cbe690913bcfce"; - hash = "sha256-z9rfVnH2qANDp2ukUGSogADbwqQQzCkB7Cp/04UtEpM="; + rev = "57deb0bd2823a9a75c5da498cc39a85f8fd4ff02"; + hash = "sha256-FzO8jKZw4EBqmsQ0xXqj0lqSHXxKk+rZjuluyNJVPYk="; }; build-system = [ diff --git a/pkgs/development/python-modules/gradio/client.nix b/pkgs/development/python-modules/gradio/client.nix index 6b988668be73..d4c02beafb07 100644 --- a/pkgs/development/python-modules/gradio/client.nix +++ b/pkgs/development/python-modules/gradio/client.nix @@ -3,7 +3,7 @@ stdenv, buildPythonPackage, fetchFromGitHub, - nix-update-script, + gitUpdater, # build-system hatchling, @@ -31,7 +31,7 @@ buildPythonPackage rec { pname = "gradio-client"; - version = "1.12.1"; + version = "2.0.1"; pyproject = true; # no tests on pypi @@ -39,13 +39,25 @@ buildPythonPackage rec { owner = "gradio-app"; repo = "gradio"; # not to be confused with @gradio/client@${version} - tag = "gradio_client@${version}"; - sparseCheckout = [ "client/python" ]; - hash = "sha256-Q0sEn7trWVVWh2XNZam10axuQBiPZvq//qTIR5WJn+4="; + # tag = "gradio_client@${version}"; + # TODO: switch back to a tag next release, if they tag it. + rev = "7a8894d7249ee20c2f7a896237e290e99661fd43"; # 2.0.1 + sparseCheckout = [ + "client/python" + "gradio/media_assets" + ]; + hash = "sha256-p3okK48DJjjyvUzedNR60r5P8aKUxjE+ocb3EplZ6Uk="; }; sourceRoot = "${src.name}/client/python"; + postPatch = '' + # Because we set sourceRoot above, the folders "client/python" + # don't exist, as far as this is concerned. + substituteInPlace test/conftest.py \ + --replace-fail 'from client.python.test import media_data' 'import media_data' + ''; + # upstream adds upper constraints because they can, not because the need to # https://github.com/gradio-app/gradio/pull/4885 pythonRelaxDeps = [ @@ -81,6 +93,11 @@ buildPythonPackage rec { # ensuring we don't propagate this intermediate build disallowedReferences = [ gradio.sans-reverse-dependencies ]; + postInstall = '' + mkdir -p $out/lib/gradio + cp -r ../../gradio/media_assets $out/lib/gradio + ''; + # Add a pytest hook skipping tests that access network, marking them as "Expected fail" (xfail). preCheck = '' cat ${./conftest-skip-network-errors.py} >> test/conftest.py @@ -110,11 +127,9 @@ buildPythonPackage rec { __darwinAllowLocalNetworking = true; - passthru.updateScript = nix-update-script { - extraArgs = [ - "--version-regex" - "gradio_client@(.*)" - ]; + passthru.updateScript = gitUpdater { + rev-prefix = "gradio_client@"; + ignoredVersions = ".*-(beta|dev).*"; }; meta = { diff --git a/pkgs/development/python-modules/gradio/conftest-skip-network-errors.py b/pkgs/development/python-modules/gradio/conftest-skip-network-errors.py index a34ee1bbcd87..a11c461d2edb 100644 --- a/pkgs/development/python-modules/gradio/conftest-skip-network-errors.py +++ b/pkgs/development/python-modules/gradio/conftest-skip-network-errors.py @@ -43,6 +43,7 @@ def deny_network_access(*a, **kw): import httpx import requests +import safehttpx import socket import urllib import urllib3 @@ -54,6 +55,7 @@ httpx.Request = deny_network_access requests.get = deny_network_access requests.head = deny_network_access requests.post = deny_network_access +safehttpx.get = deny_network_access socket.socket.connect = deny_network_access urllib.request.Request = deny_network_access urllib.request.urlopen = deny_network_access diff --git a/pkgs/development/python-modules/gradio/default.nix b/pkgs/development/python-modules/gradio/default.nix index 03872f6ecd5f..db5816d5c512 100644 --- a/pkgs/development/python-modules/gradio/default.nix +++ b/pkgs/development/python-modules/gradio/default.nix @@ -3,6 +3,7 @@ stdenv, buildPythonPackage, fetchFromGitHub, + writeScript, writeShellScriptBin, gradio, @@ -13,8 +14,8 @@ # web assets zip, - nodejs, - pnpm_9, + nodejs_24, + pnpm_10, fetchPnpmDeps, pnpmConfigHook, @@ -74,34 +75,38 @@ vega-datasets, writableTmpDirAsHomeHook, }: +let + nodejs = nodejs_24; + pnpm = pnpm_10.override { inherit nodejs; }; +in buildPythonPackage rec { pname = "gradio"; - version = "5.49.1"; + version = "6.1.0"; pyproject = true; src = fetchFromGitHub { owner = "gradio-app"; repo = "gradio"; tag = "gradio@${version}"; - hash = "sha256-tfjyu2yl+2ndPZWrsSrVf8qv2eqpU5ZJHVqM9saJVt4="; + hash = "sha256-CvlMZlZ0aN/oreCiSL7RCVz8hq9Q9EGPrnQMIxCTVUs="; }; pnpmDeps = fetchPnpmDeps { inherit pname + pnpm version src ; - pnpm = pnpm_9; - fetcherVersion = 1; - hash = "sha256-XnCx34nbX+essVfXJlxvYB9/lnolAkF81Jp6dAOqr8E="; + fetcherVersion = 3; + hash = "sha256-Lk8B2nQsKHs7JP3tjZufghXI7VL7GYfC30e/gpSSd4M="; }; pythonRelaxDeps = [ "aiofiles" "gradio-client" "markupsafe" - "pillow" + "pydantic" # Requests >=2.11.10,<=2.12.4. Staging has it, master doesn't. ]; pythonRemoveDeps = [ @@ -112,8 +117,9 @@ buildPythonPackage rec { nativeBuildInputs = [ zip nodejs + pnpm pnpmConfigHook - pnpm_9 + writableTmpDirAsHomeHook ]; build-system = [ @@ -183,7 +189,6 @@ buildPythonPackage rec { # mock calls to `shutil.which(...)` (writeShellScriptBin "npm" "false") - writableTmpDirAsHomeHook ] ++ optional-dependencies.oauth ++ pydantic.optional-dependencies.email; @@ -255,32 +260,55 @@ buildPythonPackage rec { # Flaky test (AssertionError when comparing to a fixed array) # https://github.com/gradio-app/gradio/issues/11620 "test_auto_datatype" - ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ - # TypeError: argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'NoneType' - "test_component_example_values" - "test_component_functions" - "test_public_request_pass" # Failed: DID NOT RAISE - # test.conftest.NixNetworkAccessDeniedError + # (because it raises our NixNetworkAccessDeniedError) "test_private_request_fail" - "test_theme_builder_launches" + # TypeError: argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'NoneType' + "test_component_example_values" + "test_public_request_pass" + "test_theme_builder_launches" + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ # flaky on darwin (depend on port availability) "test_all_status_messages" + "test_analytics_summary" "test_async_generators" "test_async_generators_interface" "test_async_iterator_update_with_new_component" - "test_concurrency_limits" + "test_blocks_close_closes_thread_properly" + "test_caching" + "test_caching_audio_with_progress" + "test_caching_image" + "test_caching_with_async_generators" + "test_caching_with_batch" + "test_caching_with_batch_multiple_outputs" + "test_caching_with_dict" + "test_caching_with_float_numbers" + "test_caching_with_generators" + "test_caching_with_generators_and_streamed_output" + "test_caching_with_mix_update" + "test_caching_with_non_io_component" + "test_caching_with_update" + "test_chat_interface_api_name" + "test_chat_interface_api_names_with_additional_inputs" + "test_component_returned" + "test_css_and_css_paths_parameters" + "test_custom_css" "test_default_concurrency_limits" "test_default_flagging_callback" "test_end_to_end" "test_end_to_end_cache_examples" "test_event_data" "test_every_does_not_block_queue" + "test_example_caching" + "test_example_caching_async" "test_example_caching_relaunch" - "test_example_caching_relaunch" + "test_example_caching_with_additional_inputs" + "test_example_caching_with_additional_inputs_already_rendered" + "test_example_caching_with_streaming" + "test_example_caching_with_streaming_async" "test_exit_called_at_launch" "test_file_component_uploads" "test_files_saved_as_file_paths" @@ -289,17 +317,25 @@ buildPythonPackage rec { "test_info_and_warning_alerts" "test_info_isolation" "test_launch_analytics_does_not_error_with_invalid_blocks" + "test_mcp_streamable_http_client" + "test_mcp_streamable_http_client_with_progress_callback" + "test_multiple_file_flagging" + "test_multiple_messages" "test_no_empty_audio_files" "test_no_empty_image_files" "test_no_empty_video_files" "test_non_streaming_api" "test_non_streaming_api_async" + "test_no_postprocessing" + "test_no_preprocessing" "test_pil_images_hashed" + "test_post_process_file_blocked" "test_progress_bar" "test_progress_bar_track_tqdm" "test_queue_when_using_auth" "test_restart_after_close" "test_set_share_in_colab" + "test_setting_cache_dir_env_variable" "test_show_error" "test_simple_csv_flagging_callback" "test_single_request" @@ -314,6 +350,7 @@ buildPythonPackage rec { "test_sync_generators" "test_time_to_live_and_delete_callback_for_state" "test_updates_stored_up_to_capacity" + "test_use_default_theme_as_fallback" "test_varying_output_forms_with_generators" ]; @@ -339,7 +376,10 @@ buildPythonPackage rec { pytestFlags = [ "-x" # abort on first failure - #"-Wignore" # uncomment for debugging help + # "-Wignore" # uncomment for debugging help + # Requires writable media assets in /nix/store + "--deselect" + "test/components/test_video.py::TestVideo::test_component_functions" ]; # check the binary works outside the build env @@ -351,27 +391,52 @@ buildPythonPackage rec { # Cyclic dependencies are fun! # This is gradio without gradio-client and gradio-pdf - passthru.sans-reverse-dependencies = - (gradio.override (old: { - gradio-client = null; - gradio-pdf = null; - })).overridePythonAttrs - (old: { - pname = old.pname + "-sans-reverse-dependencies"; - pythonRemoveDeps = (old.pythonRemoveDeps or [ ]) ++ [ "gradio-client" ]; - doInstallCheck = false; - doCheck = false; - preCheck = ""; - postInstall = '' - shopt -s globstar - for f in $out/**/*.py; do - cp $f "$f"i - done - shopt -u globstar - ''; - pythonImportsCheck = null; - dontCheckRuntimeDeps = true; - }); + passthru = { + sans-reverse-dependencies = + (gradio.override { + gradio-client = null; + gradio-pdf = null; + }).overridePythonAttrs + (old: { + pname = old.pname + "-sans-reverse-dependencies"; + pythonRemoveDeps = (old.pythonRemoveDeps or [ ]) ++ [ "gradio-client" ]; + doInstallCheck = false; + doCheck = false; + postPatch = ""; + preCheck = ""; + disabledTests = [ ]; + disabledTestPaths = [ ]; + disabledTestMarks = [ ]; + pytestFlags = [ ]; + postInstall = '' + shopt -s globstar + for f in $out/**/*.py; do + cp $f "$f"i + done + shopt -u globstar + ''; + pythonImportsCheck = null; + dontCheckRuntimeDeps = true; + }); + + # We can't use gitUpdater, because we need to update the pnpm hash. + # And we can't just use nix-update-script, because it often does not fetch + # 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 + + tag=$(list-git-tags \ + | grep "^gradio@" \ + | sed -e "s,^gradio@,," \ + | grep -v -E -e ".*-(beta|dev).*" \ + | sort --reverse --version-sort \ + | head -n 1 \ + | tr -d '\n' \ + ) + nix-update --version="$tag" + ''; + }; meta = { homepage = "https://www.gradio.app/";