1{ lib 2, buildPythonPackage 3, fetchFromGitHub 4, pythonOlder 5, pythonRelaxDepsHook 6# pyproject 7, hatchling 8, hatch-requirements-txt 9, hatch-fancy-pypi-readme 10# runtime 11, setuptools 12, fsspec 13, httpx 14, huggingface-hub 15, packaging 16, requests 17, typing-extensions 18, websockets 19# checkInputs 20, pytestCheckHook 21, pytest-asyncio 22, pydub 23, gradio 24}: 25 26let 27 28 # Cyclic dependencies are fun! 29 # This is gradio without gradio-client, only needed for checkPhase 30 gradio' = (gradio.override (old: { 31 gradio-client = null; 32 })).overridePythonAttrs (old: { 33 nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ pythonRelaxDepsHook ]; 34 pythonRemoveDeps = (old.pythonRemoveDeps or []) ++ [ "gradio_client" ]; 35 doInstallCheck = false; 36 doCheck = false; 37 pythonImportsCheck = null; 38 }); 39 40in 41 42buildPythonPackage rec { 43 pname = "gradio_client"; 44 version = "0.5.0"; 45 format = "pyproject"; 46 47 disabled = pythonOlder "3.8"; 48 49 # no tests on pypi 50 src = fetchFromGitHub { 51 owner = "gradio-app"; 52 repo = "gradio"; 53 #rev = "refs/tags/v${gradio.version}"; 54 rev = "ba4c6d9e65138c97062d1757d2a588c4fc449daa"; # v3.43.1 is not tagged... 55 sparseCheckout = [ "client/python" ]; 56 hash = "sha256-savka4opyZKSWPeBqc2LZqvwVXLYIZz5dS1OWJSwvHo="; 57 }; 58 prePatch = '' 59 cd client/python 60 ''; 61 62 nativeBuildInputs = [ 63 hatchling 64 hatch-requirements-txt 65 hatch-fancy-pypi-readme 66 ]; 67 68 propagatedBuildInputs = [ 69 setuptools # needed for 'pkg_resources' 70 fsspec 71 httpx 72 huggingface-hub 73 packaging 74 requests 75 typing-extensions 76 websockets 77 ]; 78 79 nativeCheckInputs =[ 80 pytestCheckHook 81 pytest-asyncio 82 pydub 83 gradio' 84 ]; 85 disallowedReferences = [ 86 gradio' # ensuring we don't propagate this intermediate build 87 ]; 88 89 # Add a pytest hook skipping tests that access network, marking them as "Expected fail" (xfail). 90 preCheck = '' 91 export HOME=$TMPDIR 92 cat ${./conftest-skip-network-errors.py} >> test/conftest.py 93 ''; 94 95 pytestFlagsArray = [ 96 "test/" 97 #"-m" "not flaky" # doesn't work, even when advertised 98 #"-x" "-W" "ignore" # uncomment for debugging help 99 ]; 100 101 pythonImportsCheck = [ "gradio_client" ]; 102 103 meta = with lib; { 104 homepage = "https://www.gradio.app/"; 105 description = "Lightweight library to use any Gradio app as an API"; 106 license = licenses.asl20; 107 maintainers = with maintainers; [ pbsds ]; 108 }; 109}