evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / development / python-modules / gradio / default.nix
blob1b9e20496f6d4a20dcccbd3f0eef10f3791f7496
2   lib,
3   stdenv,
4   buildPythonPackage,
5   fetchPypi,
6   pythonOlder,
7   writeShellScriptBin,
8   gradio,
10   # pyproject
11   hatchling,
12   hatch-requirements-txt,
13   hatch-fancy-pypi-readme,
15   # runtime
16   setuptools,
17   aiofiles,
18   anyio,
19   diffusers,
20   fastapi,
21   ffmpy,
22   gradio-client,
23   httpx,
24   huggingface-hub,
25   importlib-resources,
26   jinja2,
27   markupsafe,
28   matplotlib,
29   numpy,
30   orjson,
31   packaging,
32   pandas,
33   pillow,
34   pydantic,
35   python-multipart,
36   pydub,
37   pyyaml,
38   semantic-version,
39   typing-extensions,
40   uvicorn,
41   typer,
42   tomlkit,
44   # oauth
45   authlib,
46   itsdangerous,
48   # check
49   pytestCheckHook,
50   hypothesis,
51   altair,
52   boto3,
53   gradio-pdf,
54   ffmpeg,
55   ipython,
56   pytest-asyncio,
57   respx,
58   scikit-image,
59   torch,
60   tqdm,
61   transformers,
62   vega-datasets,
65 buildPythonPackage rec {
66   pname = "gradio";
67   version = "5.1.0";
68   pyproject = true;
70   disabled = pythonOlder "3.7";
72   # We use the Pypi release, since it provides prebuilt webui assets
73   src = fetchPypi {
74     inherit pname version;
75     hash = "sha256-0hU2aObeLfegG7M/AaB0/HcW7IY8QPRy2OQ5Q57x4VM=";
76   };
78   # fix packaging.ParserSyntaxError, which can't handle comments
79   postPatch = ''
80     sed -ie "s/ #.*$//g" requirements*.txt
82     # they bundle deps?
83     rm -rf venv/
84   '';
86   pythonRelaxDeps = [
87     "tomlkit"
88     "aiofiles"
89     "markupsafe"
90   ];
92   pythonRemoveDeps = [
93     # our package is presented as a binary, not a python lib - and
94     # this isn't a real runtime dependency
95     "ruff"
96   ];
98   build-system = [
99     hatchling
100     hatch-requirements-txt
101     hatch-fancy-pypi-readme
102   ];
104   dependencies = [
105     setuptools # needed for 'pkg_resources'
106     aiofiles
107     anyio
108     diffusers
109     fastapi
110     ffmpy
111     gradio-client
112     httpx
113     huggingface-hub
114     importlib-resources
115     jinja2
116     markupsafe
117     matplotlib
118     numpy
119     orjson
120     packaging
121     pandas
122     pillow
123     pydantic
124     python-multipart
125     pydub
126     pyyaml
127     semantic-version
128     typing-extensions
129     uvicorn
130     typer
131     tomlkit
132   ];
134   optional-dependencies.oauth = [
135     authlib
136     itsdangerous
137   ];
139   nativeCheckInputs = [
140     pytestCheckHook
141     hypothesis
142     altair
143     boto3
144     gradio-pdf
145     ffmpeg
146     ipython
147     pytest-asyncio
148     respx
149     scikit-image
150     # shap is needed as well, but breaks too often
151     torch
152     tqdm
153     transformers
154     vega-datasets
156     # mock calls to `shutil.which(...)`
157     (writeShellScriptBin "npm" "false")
158   ] ++ optional-dependencies.oauth ++ pydantic.optional-dependencies.email;
160   # Add a pytest hook skipping tests that access network, marking them as "Expected fail" (xfail).
161   # We additionally xfail FileNotFoundError, since the gradio devs often fail to upload test assets to pypi.
162   preCheck =
163     ''
164       export HOME=$TMPDIR
165       cat ${./conftest-skip-network-errors.py} >> test/conftest.py
166     ''
167     + lib.optionalString stdenv.hostPlatform.isDarwin ''
168       # OSError: [Errno 24] Too many open files
169       ulimit -n 4096
170     '';
172   disabledTests = [
173     # Actually broken
174     "test_mount_gradio_app"
175     "test_processing_utils_backwards_compatibility" # type error
177     # requires network, it caught our xfail exception
178     "test_error_analytics_successful"
180     # Flaky, tries to pin dependency behaviour. Sensitive to dep versions
181     # These error only affect downstream use of the check dependencies.
182     "test_no_color"
183     "test_in_interface_as_output"
184     "test_should_warn_url_not_having_version"
186     # Flaky, unknown reason
187     "test_in_interface"
189     # shap is too often broken in nixpkgs
190     "test_shapley_text"
192     # fails without network
193     "test_download_if_url_correct_parse"
195     # flaky: OSError: Cannot find empty port in range: 7860-7959
196     "test_docs_url"
197     "test_orjson_serialization"
198     "test_dataset_is_updated"
199     "test_multimodal_api"
201     # tests if pip and other tools are installed
202     "test_get_executable_path"
203   ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
204     # flaky on darwin (depend on port availability)
205     "test_all_status_messages"
206     "test_async_generators"
207     "test_async_generators_interface"
208     "test_async_iterator_update_with_new_component"
209     "test_concurrency_limits"
210     "test_default_concurrency_limits"
211     "test_default_flagging_callback"
212     "test_end_to_end"
213     "test_end_to_end_cache_examples"
214     "test_event_data"
215     "test_every_does_not_block_queue"
216     "test_example_caching_relaunch"
217     "test_example_caching_relaunch"
218     "test_exit_called_at_launch"
219     "test_file_component_uploads"
220     "test_files_saved_as_file_paths"
221     "test_flagging_does_not_create_unnecessary_directories"
222     "test_flagging_no_permission_error_with_flagging_disabled"
223     "test_info_and_warning_alerts"
224     "test_info_isolation"
225     "test_launch_analytics_does_not_error_with_invalid_blocks"
226     "test_no_empty_audio_files"
227     "test_no_empty_image_files"
228     "test_no_empty_video_files"
229     "test_non_streaming_api"
230     "test_non_streaming_api_async"
231     "test_pil_images_hashed"
232     "test_progress_bar"
233     "test_progress_bar_track_tqdm"
234     "test_queue_when_using_auth"
235     "test_restart_after_close"
236     "test_set_share_in_colab"
237     "test_show_error"
238     "test_simple_csv_flagging_callback"
239     "test_single_request"
240     "test_socket_reuse"
241     "test_start_server"
242     "test_state_holder_is_used_in_postprocess"
243     "test_state_stored_up_to_capacity"
244     "test_static_files_single_app"
245     "test_streaming_api"
246     "test_streaming_api_async"
247     "test_streaming_api_with_additional_inputs"
248     "test_sync_generators"
249     "test_time_to_live_and_delete_callback_for_state"
250     "test_updates_stored_up_to_capacity"
251     "test_varying_output_forms_with_generators"
252   ];
253   disabledTestPaths = [
254     # 100% touches network
255     "test/test_networking.py"
256     # makes pytest freeze 50% of the time
257     "test/test_interfaces.py"
259     # Local network tests dependant on port availability (port 7860-7959)
260     "test/test_routes.py"
261   ];
262   pytestFlagsArray = [
263     "-x" # abort on first failure
264     "-m 'not flaky'"
265     #"-W" "ignore" # uncomment for debugging help
266   ];
268   # check the binary works outside the build env
269   doInstallCheck = true;
270   postInstallCheck = ''
271     env --ignore-environment $out/bin/gradio environment >/dev/null
272   '';
274   pythonImportsCheck = [ "gradio" ];
276   # Cyclic dependencies are fun!
277   # This is gradio without gradio-client and gradio-pdf
278   passthru.sans-reverse-dependencies =
279     (gradio.override (old: {
280       gradio-client = null;
281       gradio-pdf = null;
282     })).overridePythonAttrs
283       (old: {
284         pname = old.pname + "-sans-reverse-dependencies";
285         pythonRemoveDeps = (old.pythonRemoveDeps or [ ]) ++ [ "gradio-client" ];
286         doInstallCheck = false;
287         doCheck = false;
288         preCheck = "";
289         pythonImportsCheck = null;
290         dontCheckRuntimeDeps = true;
291       });
293   meta = {
294     homepage = "https://www.gradio.app/";
295     changelog = "https://github.com/gradio-app/gradio/releases/tag/gradio@${version}";
296     description = "Python library for easily interacting with trained machine learning models";
297     license = lib.licenses.asl20;
298     maintainers = with lib.maintainers; [ pbsds ];
299   };