Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at lanzaboote 70 lines 1.6 kB view raw
1{ stdenv 2, lib 3, buildPythonPackage 4, cargo 5, fetchFromGitHub 6, h5py 7, numpy 8, pythonOlder 9, pytestCheckHook 10, rustc 11, rustPlatform 12, setuptools-rust 13, torch 14, libiconv 15}: 16 17buildPythonPackage rec { 18 pname = "safetensors"; 19 version = "0.3.3"; 20 format = "pyproject"; 21 22 disabled = pythonOlder "3.7"; 23 24 src = fetchFromGitHub { 25 owner = "huggingface"; 26 repo = pname; 27 rev = "refs/tags/v${version}"; 28 hash = "sha256-U+indMoLFN6vMZkJTWFG08lsdXuK5gOfgaHmUVl6DPk="; 29 }; 30 31 cargoDeps = rustPlatform.fetchCargoTarball { 32 inherit src; 33 sourceRoot = "${src.name}/bindings/python"; 34 hash = "sha256-MhRs9tFCmVZI5O0EVRUbo4ZnUVRQ0EfQTU+E1K+qKZI="; 35 }; 36 37 sourceRoot = "${src.name}/bindings/python"; 38 39 nativeBuildInputs = [ 40 setuptools-rust 41 cargo 42 rustc 43 rustPlatform.cargoSetupHook 44 ]; 45 46 buildInputs = lib.optionals stdenv.isDarwin [ libiconv ]; 47 48 nativeCheckInputs = [ 49 h5py numpy pytestCheckHook torch 50 ]; 51 pytestFlagsArray = [ "tests" ]; 52 # don't require PaddlePaddle (not in Nixpkgs), Flax, or Tensorflow (onerous) to run tests: 53 disabledTestPaths = [ 54 "tests/test_flax_comparison.py" 55 "tests/test_paddle_comparison.py" 56 "tests/test_tf_comparison.py" 57 ]; 58 59 pythonImportsCheck = [ 60 "safetensors" 61 ]; 62 63 meta = with lib; { 64 homepage = "https://github.com/huggingface/safetensors"; 65 description = "Fast (zero-copy) and safe (unlike pickle) format for storing tensors"; 66 changelog = "https://github.com/huggingface/safetensors/releases/tag/v${version}"; 67 license = licenses.asl20; 68 maintainers = with maintainers; [ bcdarwin ]; 69 }; 70}