1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5
6 # build-system
7 setuptools,
8 setuptools-scm,
9
10 # dependencies
11 accelerate,
12 cut-cross-entropy,
13 datasets,
14 hf-transfer,
15 huggingface-hub,
16 packaging,
17 peft,
18 psutil,
19 sentencepiece,
20 torch,
21 tqdm,
22 transformers,
23 trl,
24 tyro,
25}:
26
27buildPythonPackage rec {
28 pname = "unsloth-zoo";
29 version = "2025.4.1";
30 pyproject = true;
31
32 # no tags on GitHub
33 src = fetchPypi {
34 pname = "unsloth_zoo";
35 inherit version;
36 hash = "sha256-mRs/NMCNJWT52S7mtbQI332IQR6+/IaL29XmtMOz3fE=";
37 };
38
39 # pyproject.toml requires an obsolete version of protobuf,
40 # but it is not used.
41 # Upstream issue: https://github.com/unslothai/unsloth-zoo/pull/68
42 pythonRelaxDeps = [
43 "protobuf"
44 ];
45
46 patches = [
47 # Avoid circular dependency in Nix, since `unsloth` depends on `unsloth-zoo`.
48 ./dont-require-unsloth.patch
49 ];
50
51 build-system = [
52 setuptools
53 setuptools-scm
54 ];
55
56 dependencies = [
57 accelerate
58 cut-cross-entropy
59 datasets
60 hf-transfer
61 huggingface-hub
62 packaging
63 peft
64 psutil
65 sentencepiece
66 torch
67 tqdm
68 transformers
69 trl
70 tyro
71 ];
72
73 # No tests
74 doCheck = false;
75
76 pythonImportsCheck = [
77 "unsloth_zoo"
78 ];
79
80 meta = {
81 description = "Utils for Unsloth";
82 homepage = "https://github.com/unslothai/unsloth_zoo";
83 license = lib.licenses.mit;
84 maintainers = with lib.maintainers; [ hoh ];
85 };
86}