1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 pdm-backend,
9
10 # dependencies
11 huggingface-hub,
12 pyyaml,
13 safetensors,
14 torch,
15 torchvision,
16
17 # tests
18 expecttest,
19 pytestCheckHook,
20 pytest-timeout,
21 pythonAtLeast,
22}:
23
24buildPythonPackage rec {
25 pname = "timm";
26 version = "1.0.15";
27 pyproject = true;
28
29 src = fetchFromGitHub {
30 owner = "huggingface";
31 repo = "pytorch-image-models";
32 tag = "v${version}";
33 hash = "sha256-TXc+D8GRrO46q88fOH44ZHKOGnCdP47ipEcobnGTxWU=";
34 };
35
36 build-system = [ pdm-backend ];
37
38 dependencies = [
39 huggingface-hub
40 pyyaml
41 safetensors
42 torch
43 torchvision
44 ];
45
46 nativeCheckInputs = [
47 expecttest
48 pytestCheckHook
49 pytest-timeout
50 ];
51
52 pytestFlagsArray = [ "tests" ];
53
54 disabledTests =
55 lib.optionals
56 (
57 # RuntimeError: Dynamo is not supported on Python 3.13+
58 (pythonAtLeast "3.13")
59
60 # torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised:
61 # CppCompileError: C++ compile error
62 # OpenMP support not found.
63 || stdenv.hostPlatform.isDarwin
64 )
65 [
66 "test_kron"
67 ];
68
69 disabledTestPaths = [
70 # Takes too long and also tries to download models
71 "tests/test_models.py"
72 ];
73
74 pythonImportsCheck = [
75 "timm"
76 "timm.data"
77 ];
78
79 meta = {
80 description = "PyTorch image models, scripts, and pretrained weights";
81 homepage = "https://huggingface.co/docs/timm/index";
82 changelog = "https://github.com/huggingface/pytorch-image-models/blob/v${version}/README.md#whats-new";
83 license = lib.licenses.asl20;
84 maintainers = with lib.maintainers; [ bcdarwin ];
85 };
86}