1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
{ stdenv
, lib
, buildPythonPackage
, cargo
, fetchFromGitHub
, fetchpatch
, h5py
, numpy
, pythonOlder
, pytestCheckHook
, rustc
, rustPlatform
, setuptools-rust
, torch
, libiconv
}:
buildPythonPackage rec {
pname = "safetensors";
version = "0.3.0";
format = "pyproject";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "huggingface";
repo = pname;
rev = "refs/tags/v${version}";
hash = "sha256-Qpb5lTw1WEME9tWEGfxC8l8dK9mGMH2rz+O+xGCrUxw";
};
patches = [
# remove after next release
(fetchpatch {
name = "commit-cargo-lockfile";
relative = "bindings/python";
url = "https://github.com/huggingface/safetensors/commit/a7061b4235b59312010b2dd6f9597381428ee9a2.patch";
hash = "sha256-iH4vQOL2LU93kd0dSS8/JJxKGb+kDstqnExjYSSwi78";
})
];
cargoDeps = rustPlatform.fetchCargoTarball {
inherit src patches;
sourceRoot = "source/bindings/python";
hash = "sha256-tC0XawmKWNGCaByHQfJEfmHM3m/qgTuIpcRaEFJC6dM";
};
sourceRoot = "source/bindings/python";
nativeBuildInputs = [
setuptools-rust
cargo
rustc
rustPlatform.cargoSetupHook
];
buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
nativeCheckInputs = [
h5py numpy pytestCheckHook torch
];
pytestFlagsArray = [ "tests" ];
# don't require PaddlePaddle (not in Nixpkgs), Flax, or Tensorflow (onerous) to run tests:
disabledTestPaths = [
"tests/test_flax_comparison.py"
"tests/test_paddle_comparison.py"
"tests/test_tf_comparison.py"
];
pythonImportsCheck = [
"safetensors"
];
meta = with lib; {
homepage = "https://github.com/huggingface/safetensors";
description = "Fast (zero-copy) and safe (unlike pickle) format for storing tensors";
changelog = "https://github.com/huggingface/safetensors/releases/tag/v${version}";
license = licenses.asl20;
maintainers = with maintainers; [ bcdarwin ];
};
}
|