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}:
22
23buildPythonPackage rec {
24 pname = "timm";
25 version = "1.0.20";
26 pyproject = true;
27
28 src = fetchFromGitHub {
29 owner = "huggingface";
30 repo = "pytorch-image-models";
31 tag = "v${version}";
32 hash = "sha256-OdbhL7vDeNMCEROfEI37T162k5iQ02Qdcwr3aObVqPQ=";
33 };
34
35 build-system = [ pdm-backend ];
36
37 dependencies = [
38 huggingface-hub
39 pyyaml
40 safetensors
41 torch
42 torchvision
43 ];
44
45 nativeCheckInputs = [
46 expecttest
47 pytestCheckHook
48 pytest-timeout
49 ];
50
51 enabledTestPaths = [ "tests" ];
52
53 disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
54 # torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised:
55 # CppCompileError: C++ compile error
56 # OpenMP support not found.
57 "test_kron"
58 ];
59
60 disabledTestPaths = [
61 # Takes too long and also tries to download models
62 "tests/test_models.py"
63 ];
64
65 pythonImportsCheck = [
66 "timm"
67 "timm.data"
68 ];
69
70 meta = {
71 description = "PyTorch image models, scripts, and pretrained weights";
72 homepage = "https://huggingface.co/docs/timm/index";
73 changelog = "https://github.com/huggingface/pytorch-image-models/blob/v${version}/README.md#whats-new";
74 license = lib.licenses.asl20;
75 maintainers = with lib.maintainers; [ bcdarwin ];
76 };
77}