1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 gitUpdater, 6 pythonOlder, 7 pythonRelaxDepsHook, 8 # pyproject 9 hatchling, 10 hatch-requirements-txt, 11 hatch-fancy-pypi-readme, 12 # runtime 13 setuptools, 14 fsspec, 15 httpx, 16 huggingface-hub, 17 packaging, 18 requests, 19 typing-extensions, 20 websockets, 21 # checkInputs 22 pytestCheckHook, 23 pytest-asyncio, 24 pydub, 25 rich, 26 tomlkit, 27 gradio, 28}: 29 30buildPythonPackage rec { 31 pname = "gradio-client"; 32 version = "0.16.1"; 33 pyproject = true; 34 35 disabled = pythonOlder "3.8"; 36 37 # no tests on pypi 38 src = fetchFromGitHub { 39 owner = "gradio-app"; 40 repo = "gradio"; 41 rev = "refs/tags/gradio_client@${version}"; 42 sparseCheckout = [ "client/python" ]; 43 hash = "sha256-SVUm9LrjYG0r3U1yOd3rctxVMYlnAOW+Opqy9c3osnw="; 44 }; 45 prePatch = '' 46 cd client/python 47 ''; 48 49 # upstream adds upper constraints because they can, not because the need to 50 # https://github.com/gradio-app/gradio/pull/4885 51 pythonRelaxDeps = [ 52 # only backward incompat is dropping py3.7 support 53 "websockets" 54 ]; 55 56 build-system = [ 57 hatchling 58 hatch-requirements-txt 59 hatch-fancy-pypi-readme 60 pythonRelaxDepsHook 61 ]; 62 63 dependencies = [ 64 setuptools # needed for 'pkg_resources' 65 fsspec 66 httpx 67 huggingface-hub 68 packaging 69 typing-extensions 70 websockets 71 ]; 72 73 nativeCheckInputs = [ 74 pytestCheckHook 75 pytest-asyncio 76 pydub 77 rich 78 tomlkit 79 gradio.sans-reverse-dependencies 80 ]; 81 # ensuring we don't propagate this intermediate build 82 disallowedReferences = [ gradio.sans-reverse-dependencies ]; 83 84 # Add a pytest hook skipping tests that access network, marking them as "Expected fail" (xfail). 85 preCheck = '' 86 export HOME=$TMPDIR 87 cat ${./conftest-skip-network-errors.py} >> test/conftest.py 88 ''; 89 90 pytestFlagsArray = [ 91 "test/" 92 "-m 'not flaky'" 93 #"-x" "-W" "ignore" # uncomment for debugging help 94 ]; 95 96 pythonImportsCheck = [ "gradio_client" ]; 97 98 __darwinAllowLocalNetworking = true; 99 100 passthru.updateScript = gitUpdater { rev-prefix = "@gradio/client@"; }; 101 102 meta = with lib; { 103 homepage = "https://www.gradio.app/"; 104 description = "Lightweight library to use any Gradio app as an API"; 105 license = licenses.asl20; 106 maintainers = with maintainers; [ pbsds ]; 107 }; 108}