about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/gradio/default.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-08-23 10:09:14 +0000
committerAlyssa Ross <hi@alyssa.is>2023-08-26 09:07:03 +0000
commit63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f (patch)
treed58934cb48f9c953b19a0d0d5cffc0d0c5561471 /nixpkgs/pkgs/development/python-modules/gradio/default.nix
parentc4eef3dacb2a3d359561f30917d9e3cc4e041be9 (diff)
parent91a22f76cd1716f9d0149e8a5c68424bb691de15 (diff)
downloadnixlib-63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f.tar
nixlib-63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f.tar.gz
nixlib-63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f.tar.bz2
nixlib-63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f.tar.lz
nixlib-63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f.tar.xz
nixlib-63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f.tar.zst
nixlib-63dabcc77ef9a56655e1ca2ab2e25e6163a72c1f.zip
Merge branch 'nixos-unstable' of https://github.com/NixOS/nixpkgs
Conflicts:
	nixpkgs/pkgs/build-support/go/module.nix
	nixpkgs/pkgs/development/python-modules/django-mailman3/default.nix
Diffstat (limited to 'nixpkgs/pkgs/development/python-modules/gradio/default.nix')
-rw-r--r--nixpkgs/pkgs/development/python-modules/gradio/default.nix175
1 files changed, 175 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/python-modules/gradio/default.nix b/nixpkgs/pkgs/development/python-modules/gradio/default.nix
new file mode 100644
index 000000000000..ffb99d729328
--- /dev/null
+++ b/nixpkgs/pkgs/development/python-modules/gradio/default.nix
@@ -0,0 +1,175 @@
+{ lib
+, buildPythonPackage
+, fetchPypi
+, pythonOlder
+, pythonRelaxDepsHook
+, writeText
+
+# pyproject
+, hatchling
+, hatch-requirements-txt
+, hatch-fancy-pypi-readme
+
+# runtime
+, setuptools
+, aiofiles
+, aiohttp
+, altair
+, fastapi
+, ffmpy
+, markdown-it-py
+, mdit-py-plugins
+, markupsafe
+, matplotlib
+, numpy
+, orjson
+, pandas
+, pillow
+, pycryptodome
+, python-multipart
+, pydub
+, pyyaml
+, requests
+, uvicorn
+, jinja2
+, fsspec
+, httpx
+, pydantic
+, websockets
+, typing-extensions
+
+# check
+, pytestCheckHook
+, pytest-asyncio
+, mlflow
+, huggingface-hub
+, transformers
+, wandb
+, respx
+, scikit-image
+, ipython
+, ffmpeg
+, vega_datasets
+, boto3
+}:
+
+buildPythonPackage rec {
+  pname = "gradio";
+  version = "3.20.1";
+  format = "pyproject";
+
+  disabled = pythonOlder "3.7";
+
+  # We use the Pypi release, as it provides prebuilt webui assets,
+  # and has more frequent releases compared to github tags
+  src = fetchPypi {
+    inherit pname version;
+    hash = "sha256-oG97GwehyBWjWXzDqyfj+x2mAfM6OQhYKdA3j0Rv8Vs=";
+  };
+
+  pythonRelaxDeps = [
+    "mdit-py-plugins"
+  ];
+
+  nativeBuildInputs = [
+    pythonRelaxDepsHook
+    hatchling
+    hatch-requirements-txt
+    hatch-fancy-pypi-readme
+  ];
+
+  propagatedBuildInputs = [
+    setuptools # needs pkg_resources
+    aiofiles
+    aiohttp
+    altair
+    fastapi
+    ffmpy
+    markdown-it-py
+    mdit-py-plugins
+    markupsafe
+    matplotlib
+    numpy
+    orjson
+    pandas
+    pillow
+    pycryptodome
+    python-multipart
+    pydub
+    pyyaml
+    requests
+    uvicorn
+    jinja2
+    fsspec
+    httpx
+    pydantic
+    websockets
+    typing-extensions
+  ] ++ markdown-it-py.optional-dependencies.linkify;
+
+  nativeCheckInputs = [
+    pytestCheckHook
+    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
+  ];
+
+  # 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 ''
+    export HOME=$TMPDIR
+    cat ${./conftest-skip-network-errors.py} >> test/conftest.py
+  '';
+
+  disabledTests = [
+    # Actually broken
+    "test_mount_gradio_app"
+
+    # FIXME: enable once comet-ml is packaged
+    "test_inline_display"
+    "test_integration_comet"
+
+    # Flaky, tries to pin dependency behaviour. Sensitive to dep versions
+    # These error only affect downstream use of the check dependencies.
+    "test_no_color"
+    "test_in_interface_as_output"
+    "test_should_warn_url_not_having_version"
+
+    # Flaky, unknown reason
+    "test_in_interface"
+
+    # shap is too often broken in nixpkgs
+    "test_shapley_text"
+  ];
+  disabledTestPaths = [
+    # makes pytest freeze 50% of the time
+    "test/test_interfaces.py"
+  ];
+  #pytestFlagsArray = [ "-x" "-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
+  '';
+
+  pythonImportsCheck = [ "gradio" ];
+
+  meta = with lib; {
+    homepage = "https://www.gradio.app/";
+    description = "Python library for easily interacting with trained machine learning models";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ pbsds ];
+  };
+}