17 # optional dependencies
40 buildPythonPackage rec {
45 disabled = pythonOlder "3.8";
47 src = fetchFromGitHub {
48 owner = "huggingface";
50 rev = "refs/tags/v${version}";
51 hash = "sha256-aRnbU3jN40xaCsoMFyRt1XB+hyIYMJP2b/T1yZho90c=";
59 propagatedBuildInputs = [
70 passthru.optional-dependencies = {
90 pythonImportsCheck = [
94 # tests crash due to torch segmentation fault
95 doCheck = !(stdenv.isLinux && stdenv.isAarch64);
107 ] ++ passthru.optional-dependencies.torch;
110 # This pytest hook mocks and catches attempts at accessing the network
111 # tests that try to access the network will raise, get caught, be marked as skipped and tagged as xfailed.
112 # cf. python3Packages.shap
113 conftestSkipNetworkErrors = writeText "conftest.py" ''
114 from _pytest.runner import pytest_runtest_makereport as orig_pytest_runtest_makereport
117 class NetworkAccessDeniedError(RuntimeError): pass
118 def deny_network_access(*a, **kw):
119 raise NetworkAccessDeniedError
121 urllib3.connection.HTTPSConnection._new_conn = deny_network_access
123 def pytest_runtest_makereport(item, call):
124 tr = orig_pytest_runtest_makereport(item, call)
125 if call.excinfo is not None and call.excinfo.type is NetworkAccessDeniedError:
126 tr.outcome = 'skipped'
127 tr.wasxfail = "reason: Requires network access."
132 cat ${conftestSkipNetworkErrors} >> tests/conftest.py
140 # depends on current working directory
141 "test_deprecate_stacklevel"
142 # fails due to precision of floating point numbers
143 "test_model_cpu_offload_forward_pass"
144 # tries to run ruff which we have intentionally removed from nativeCheckInputs
145 "test_is_copy_consistent"
149 description = "State-of-the-art diffusion models for image and audio generation in PyTorch";
150 mainProgram = "diffusers-cli";
151 homepage = "https://github.com/huggingface/diffusers";
152 changelog = "https://github.com/huggingface/diffusers/releases/tag/${src.rev}";
153 license = licenses.asl20;
154 maintainers = with maintainers; [ natsukium ];