diff options
Diffstat (limited to 'nixpkgs/pkgs/development/python-modules/gradio')
-rw-r--r-- | nixpkgs/pkgs/development/python-modules/gradio/client.nix | 109 | ||||
-rw-r--r-- | nixpkgs/pkgs/development/python-modules/gradio/default.nix | 97 |
2 files changed, 157 insertions, 49 deletions
diff --git a/nixpkgs/pkgs/development/python-modules/gradio/client.nix b/nixpkgs/pkgs/development/python-modules/gradio/client.nix new file mode 100644 index 000000000000..ce866a67b4cc --- /dev/null +++ b/nixpkgs/pkgs/development/python-modules/gradio/client.nix @@ -0,0 +1,109 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, pythonOlder +, pythonRelaxDepsHook +# pyproject +, hatchling +, hatch-requirements-txt +, hatch-fancy-pypi-readme +# runtime +, setuptools +, fsspec +, httpx +, huggingface-hub +, packaging +, requests +, typing-extensions +, websockets +# checkInputs +, pytestCheckHook +, pytest-asyncio +, pydub +, gradio +}: + +let + + # Cyclic dependencies are fun! + # This is gradio without gradio-client, only needed for checkPhase + gradio' = (gradio.override (old: { + gradio-client = null; + })).overridePythonAttrs (old: { + nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ pythonRelaxDepsHook ]; + pythonRemoveDeps = (old.pythonRemoveDeps or []) ++ [ "gradio_client" ]; + doInstallCheck = false; + doCheck = false; + pythonImportsCheck = null; + }); + +in + +buildPythonPackage rec { + pname = "gradio_client"; + version = "0.5.0"; + format = "pyproject"; + + disabled = pythonOlder "3.8"; + + # no tests on pypi + src = fetchFromGitHub { + owner = "gradio-app"; + repo = "gradio"; + #rev = "refs/tags/v${gradio.version}"; + rev = "ba4c6d9e65138c97062d1757d2a588c4fc449daa"; # v3.43.1 is not tagged... + sparseCheckout = [ "client/python" ]; + hash = "sha256-savka4opyZKSWPeBqc2LZqvwVXLYIZz5dS1OWJSwvHo="; + }; + prePatch = '' + cd client/python + ''; + + nativeBuildInputs = [ + hatchling + hatch-requirements-txt + hatch-fancy-pypi-readme + ]; + + propagatedBuildInputs = [ + setuptools # needed for 'pkg_resources' + fsspec + httpx + huggingface-hub + packaging + requests + typing-extensions + websockets + ]; + + nativeCheckInputs =[ + pytestCheckHook + pytest-asyncio + pydub + gradio' + ]; + disallowedReferences = [ + gradio' # ensuring we don't propagate this intermediate build + ]; + + # Add a pytest hook skipping tests that access network, marking them as "Expected fail" (xfail). + preCheck = '' + export HOME=$TMPDIR + cat ${./conftest-skip-network-errors.py} >> test/conftest.py + ''; + + pytestFlagsArray = [ + "test/" + #"-m" "not flaky" # doesn't work, even when advertised + #"-x" "-W" "ignore" # uncomment for debugging help + ]; + + pythonImportsCheck = [ "gradio_client" ]; + + meta = with lib; { + homepage = "https://www.gradio.app/"; + description = "Lightweight library to use any Gradio app as an API"; + license = licenses.asl20; + maintainers = with maintainers; [ pbsds ]; + }; +} diff --git a/nixpkgs/pkgs/development/python-modules/gradio/default.nix b/nixpkgs/pkgs/development/python-modules/gradio/default.nix index ffb99d729328..c09b55496bef 100644 --- a/nixpkgs/pkgs/development/python-modules/gradio/default.nix +++ b/nixpkgs/pkgs/development/python-modules/gradio/default.nix @@ -3,7 +3,6 @@ , fetchPypi , pythonOlder , pythonRelaxDepsHook -, writeText # pyproject , hatchling @@ -13,49 +12,48 @@ # runtime , setuptools , aiofiles -, aiohttp , altair , fastapi , ffmpy -, markdown-it-py -, mdit-py-plugins +, gradio-client +, httpx +, huggingface-hub +, importlib-resources +, jinja2 , markupsafe , matplotlib , numpy , orjson +, packaging , pandas , pillow -, pycryptodome +, pydantic , python-multipart , pydub , pyyaml , requests +, semantic-version +, typing-extensions , uvicorn -, jinja2 -, fsspec -, httpx -, pydantic , websockets -, typing-extensions # check , pytestCheckHook +, boto3 +, ffmpeg +, ipython , pytest-asyncio -, mlflow -, huggingface-hub -, transformers -, wandb , respx , scikit-image -, ipython -, ffmpeg +, torch +, tqdm +, transformers , vega_datasets -, boto3 }: buildPythonPackage rec { pname = "gradio"; - version = "3.20.1"; + version = "3.43.1"; format = "pyproject"; disabled = pythonOlder "3.7"; @@ -64,12 +62,13 @@ buildPythonPackage rec { # and has more frequent releases compared to github tags src = fetchPypi { inherit pname version; - hash = "sha256-oG97GwehyBWjWXzDqyfj+x2mAfM6OQhYKdA3j0Rv8Vs="; + hash = "sha256-a8eHw8jedrse1dpgup9BL60oXx4wvOk8X5z5DP1DWOs="; }; - pythonRelaxDeps = [ - "mdit-py-plugins" - ]; + # fix packaging.ParserSyntaxError, which can't handle comments + postPatch = '' + sed -ie "s/ #.*$//g" requirements*.txt + ''; nativeBuildInputs = [ pythonRelaxDepsHook @@ -79,55 +78,52 @@ buildPythonPackage rec { ]; propagatedBuildInputs = [ - setuptools # needs pkg_resources + setuptools # needed for 'pkg_resources' aiofiles - aiohttp altair fastapi ffmpy - markdown-it-py - mdit-py-plugins + gradio-client + httpx + huggingface-hub + importlib-resources + jinja2 markupsafe matplotlib numpy orjson + packaging pandas pillow - pycryptodome + pydantic python-multipart pydub pyyaml requests + semantic-version + typing-extensions uvicorn - jinja2 - fsspec - httpx - pydantic websockets - typing-extensions - ] ++ markdown-it-py.optional-dependencies.linkify; + ]; nativeCheckInputs = [ pytestCheckHook + boto3 + ffmpeg + ipython pytest-asyncio - mlflow - #comet-ml # FIXME: enable once packaged - huggingface-hub - transformers - wandb respx scikit-image - ipython - ffmpeg - vega_datasets - boto3 # shap is needed as well, but breaks too often + torch + tqdm + transformers + vega_datasets ]; # Add a pytest hook skipping tests that access network, marking them as "Expected fail" (xfail). # We additionally xfail FileNotFoundError, since the gradio devs often fail to upload test assets to pypi. - preCheck = let - in '' + preCheck = '' export HOME=$TMPDIR cat ${./conftest-skip-network-errors.py} >> test/conftest.py ''; @@ -136,9 +132,8 @@ buildPythonPackage rec { # Actually broken "test_mount_gradio_app" - # FIXME: enable once comet-ml is packaged - "test_inline_display" - "test_integration_comet" + # requires network, it caught our xfail exception + "test_error_analytics_successful" # Flaky, tries to pin dependency behaviour. Sensitive to dep versions # These error only affect downstream use of the check dependencies. @@ -156,12 +151,16 @@ buildPythonPackage rec { # makes pytest freeze 50% of the time "test/test_interfaces.py" ]; - #pytestFlagsArray = [ "-x" "-W" "ignore" ]; # uncomment for debugging help + pytestFlagsArray = [ + "-x" # abort on first failure + #"-m" "not flaky" # doesn't work, even when advertised + #"-W" "ignore" # uncomment for debugging help + ]; # check the binary works outside the build env doInstallCheck = true; postInstallCheck = '' - env --ignore-environment $out/bin/gradio --help >/dev/null + env --ignore-environment $out/bin/gradio environment >/dev/null ''; pythonImportsCheck = [ "gradio" ]; |