2023-08-22 20:05:09 +00:00
|
|
|
{ lib
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchPypi
|
|
|
|
, pythonOlder
|
|
|
|
, pythonRelaxDepsHook
|
|
|
|
|
|
|
|
# pyproject
|
|
|
|
, hatchling
|
|
|
|
, hatch-requirements-txt
|
|
|
|
, hatch-fancy-pypi-readme
|
|
|
|
|
|
|
|
# runtime
|
|
|
|
, setuptools
|
|
|
|
, aiofiles
|
|
|
|
, altair
|
|
|
|
, fastapi
|
|
|
|
, ffmpy
|
2023-10-09 19:29:22 +00:00
|
|
|
, gradio-client
|
|
|
|
, httpx
|
|
|
|
, huggingface-hub
|
|
|
|
, importlib-resources
|
|
|
|
, jinja2
|
2023-08-22 20:05:09 +00:00
|
|
|
, markupsafe
|
|
|
|
, matplotlib
|
|
|
|
, numpy
|
|
|
|
, orjson
|
2023-10-09 19:29:22 +00:00
|
|
|
, packaging
|
2023-08-22 20:05:09 +00:00
|
|
|
, pandas
|
|
|
|
, pillow
|
2023-10-09 19:29:22 +00:00
|
|
|
, pydantic
|
2023-08-22 20:05:09 +00:00
|
|
|
, python-multipart
|
|
|
|
, pydub
|
|
|
|
, pyyaml
|
|
|
|
, requests
|
2023-10-09 19:29:22 +00:00
|
|
|
, semantic-version
|
|
|
|
, typing-extensions
|
2023-08-22 20:05:09 +00:00
|
|
|
, uvicorn
|
|
|
|
, websockets
|
|
|
|
|
|
|
|
# check
|
|
|
|
, pytestCheckHook
|
2023-10-09 19:29:22 +00:00
|
|
|
, boto3
|
|
|
|
, ffmpeg
|
|
|
|
, ipython
|
2023-08-22 20:05:09 +00:00
|
|
|
, pytest-asyncio
|
|
|
|
, respx
|
|
|
|
, scikit-image
|
2023-10-09 19:29:22 +00:00
|
|
|
, torch
|
|
|
|
, tqdm
|
|
|
|
, transformers
|
2023-08-22 20:05:09 +00:00
|
|
|
, vega_datasets
|
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "gradio";
|
2023-10-09 19:29:22 +00:00
|
|
|
version = "3.43.1";
|
2023-08-22 20:05:09 +00:00
|
|
|
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;
|
2023-10-09 19:29:22 +00:00
|
|
|
hash = "sha256-a8eHw8jedrse1dpgup9BL60oXx4wvOk8X5z5DP1DWOs=";
|
2023-08-22 20:05:09 +00:00
|
|
|
};
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
# fix packaging.ParserSyntaxError, which can't handle comments
|
|
|
|
postPatch = ''
|
|
|
|
sed -ie "s/ #.*$//g" requirements*.txt
|
|
|
|
'';
|
2023-08-22 20:05:09 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pythonRelaxDepsHook
|
|
|
|
hatchling
|
|
|
|
hatch-requirements-txt
|
|
|
|
hatch-fancy-pypi-readme
|
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
2023-10-09 19:29:22 +00:00
|
|
|
setuptools # needed for 'pkg_resources'
|
2023-08-22 20:05:09 +00:00
|
|
|
aiofiles
|
|
|
|
altair
|
|
|
|
fastapi
|
|
|
|
ffmpy
|
2023-10-09 19:29:22 +00:00
|
|
|
gradio-client
|
|
|
|
httpx
|
|
|
|
huggingface-hub
|
|
|
|
importlib-resources
|
|
|
|
jinja2
|
2023-08-22 20:05:09 +00:00
|
|
|
markupsafe
|
|
|
|
matplotlib
|
|
|
|
numpy
|
|
|
|
orjson
|
2023-10-09 19:29:22 +00:00
|
|
|
packaging
|
2023-08-22 20:05:09 +00:00
|
|
|
pandas
|
|
|
|
pillow
|
2023-10-09 19:29:22 +00:00
|
|
|
pydantic
|
2023-08-22 20:05:09 +00:00
|
|
|
python-multipart
|
|
|
|
pydub
|
|
|
|
pyyaml
|
|
|
|
requests
|
2023-10-09 19:29:22 +00:00
|
|
|
semantic-version
|
|
|
|
typing-extensions
|
2023-08-22 20:05:09 +00:00
|
|
|
uvicorn
|
|
|
|
websockets
|
2023-10-09 19:29:22 +00:00
|
|
|
];
|
2023-08-22 20:05:09 +00:00
|
|
|
|
|
|
|
nativeCheckInputs = [
|
|
|
|
pytestCheckHook
|
2023-10-09 19:29:22 +00:00
|
|
|
boto3
|
|
|
|
ffmpeg
|
|
|
|
ipython
|
2023-08-22 20:05:09 +00:00
|
|
|
pytest-asyncio
|
|
|
|
respx
|
|
|
|
scikit-image
|
|
|
|
# shap is needed as well, but breaks too often
|
2023-10-09 19:29:22 +00:00
|
|
|
torch
|
|
|
|
tqdm
|
|
|
|
transformers
|
|
|
|
vega_datasets
|
2023-08-22 20:05:09 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# 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.
|
2023-10-09 19:29:22 +00:00
|
|
|
preCheck = ''
|
2023-08-22 20:05:09 +00:00
|
|
|
export HOME=$TMPDIR
|
|
|
|
cat ${./conftest-skip-network-errors.py} >> test/conftest.py
|
|
|
|
'';
|
|
|
|
|
|
|
|
disabledTests = [
|
|
|
|
# Actually broken
|
|
|
|
"test_mount_gradio_app"
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
# requires network, it caught our xfail exception
|
|
|
|
"test_error_analytics_successful"
|
2023-08-22 20:05:09 +00:00
|
|
|
|
|
|
|
# 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"
|
|
|
|
];
|
2023-10-09 19:29:22 +00:00
|
|
|
pytestFlagsArray = [
|
|
|
|
"-x" # abort on first failure
|
|
|
|
#"-m" "not flaky" # doesn't work, even when advertised
|
|
|
|
#"-W" "ignore" # uncomment for debugging help
|
|
|
|
];
|
2023-08-22 20:05:09 +00:00
|
|
|
|
|
|
|
# check the binary works outside the build env
|
|
|
|
doInstallCheck = true;
|
|
|
|
postInstallCheck = ''
|
2023-10-09 19:29:22 +00:00
|
|
|
env --ignore-environment $out/bin/gradio environment >/dev/null
|
2023-08-22 20:05:09 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|