12 hatch-requirements-txt,
13 hatch-fancy-pypi-readme,
65 buildPythonPackage rec {
70 disabled = pythonOlder "3.7";
72 # We use the Pypi release, since it provides prebuilt webui assets
74 inherit pname version;
75 hash = "sha256-0hU2aObeLfegG7M/AaB0/HcW7IY8QPRy2OQ5Q57x4VM=";
78 # fix packaging.ParserSyntaxError, which can't handle comments
80 sed -ie "s/ #.*$//g" requirements*.txt
93 # our package is presented as a binary, not a python lib - and
94 # this isn't a real runtime dependency
100 hatch-requirements-txt
101 hatch-fancy-pypi-readme
105 setuptools # needed for 'pkg_resources'
134 optional-dependencies.oauth = [
139 nativeCheckInputs = [
150 # shap is needed as well, but breaks too often
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.
165 cat ${./conftest-skip-network-errors.py} >> test/conftest.py
167 + lib.optionalString stdenv.hostPlatform.isDarwin ''
168 # OSError: [Errno 24] Too many open files
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.
183 "test_in_interface_as_output"
184 "test_should_warn_url_not_having_version"
186 # Flaky, unknown reason
189 # shap is too often broken in nixpkgs
192 # fails without network
193 "test_download_if_url_correct_parse"
195 # flaky: OSError: Cannot find empty port in range: 7860-7959
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"
213 "test_end_to_end_cache_examples"
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"
233 "test_progress_bar_track_tqdm"
234 "test_queue_when_using_auth"
235 "test_restart_after_close"
236 "test_set_share_in_colab"
238 "test_simple_csv_flagging_callback"
239 "test_single_request"
242 "test_state_holder_is_used_in_postprocess"
243 "test_state_stored_up_to_capacity"
244 "test_static_files_single_app"
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"
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"
263 "-x" # abort on first failure
265 #"-W" "ignore" # uncomment for debugging help
268 # check the binary works outside the build env
269 doInstallCheck = true;
270 postInstallCheck = ''
271 env --ignore-environment $out/bin/gradio environment >/dev/null
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;
282 })).overridePythonAttrs
284 pname = old.pname + "-sans-reverse-dependencies";
285 pythonRemoveDeps = (old.pythonRemoveDeps or [ ]) ++ [ "gradio-client" ];
286 doInstallCheck = false;
289 pythonImportsCheck = null;
290 dontCheckRuntimeDeps = true;
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 ];