nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 pythonAtLeast,
7
8 # build-system
9 pdm-backend,
10
11 # dependencies
12 huggingface-hub,
13 pyyaml,
14 safetensors,
15 torch,
16 torchvision,
17
18 # tests
19 expecttest,
20 pytestCheckHook,
21 pytest-timeout,
22}:
23
24buildPythonPackage (finalAttrs: {
25 pname = "timm";
26 version = "1.0.25";
27 pyproject = true;
28
29 src = fetchFromGitHub {
30 owner = "huggingface";
31 repo = "pytorch-image-models";
32 tag = "v${finalAttrs.version}";
33 hash = "sha256-ulF94vSc4DQjVH6kZ+wFsrdmGRK+zpRk2ImWuF46xwE=";
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 enabledTestPaths = [ "tests" ];
53
54 disabledTests =
55 lib.optionals (pythonAtLeast "3.14") [
56 # RuntimeError: torch.compile is not supported on Python 3.14+
57 "test_kron"
58
59 # AttributeError: 'LsePlus2d' object has no attribute '__annotations__'. Did you mean: '__annotate_func__'?
60 "test_torchscript"
61 ]
62 ++ lib.optionals stdenv.hostPlatform.isDarwin [
63 # torch._dynamo.exc.BackendCompilerFailed: backend='inductor' raised:
64 # CppCompileError: C++ compile error
65 # OpenMP support not found.
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/${finalAttrs.src.tag}/README.md#whats-new";
83 license = lib.licenses.asl20;
84 maintainers = with lib.maintainers; [ bcdarwin ];
85 };
86})