diff options
author | Mario Rodas <marsam@users.noreply.github.com> | 2023-04-24 20:36:17 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-24 20:36:17 -0500 |
commit | 3229369c6d4583fa81afdea9816cf7e557d5bc1e (patch) | |
tree | 3c72e35b1e4cd989d0d8182833edc44466455a7a | |
parent | 86056980f2ff16ed149350411d8219d68c18583e (diff) | |
parent | 26b3ecb50a1182285c85a0a26dc314b4d5c1354b (diff) |
Merge pull request #226060 from bcdarwin/python3-safetensors
python310Packages.safetensors: init at 0.3.0
-rw-r--r-- | pkgs/development/python-modules/safetensors/default.nix | 79 | ||||
-rw-r--r-- | pkgs/top-level/python-packages.nix | 2 |
2 files changed, 81 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/safetensors/default.nix b/pkgs/development/python-modules/safetensors/default.nix new file mode 100644 index 0000000000000..407dc5bebbe8d --- /dev/null +++ b/pkgs/development/python-modules/safetensors/default.nix @@ -0,0 +1,79 @@ +{ stdenv +, lib +, buildPythonPackage +, fetchFromGitHub +, fetchpatch +, h5py +, numpy +, pythonOlder +, pytestCheckHook +, 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 = with rustPlatform; [ + setuptools-rust + rust.cargo + rust.rustc + 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 ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 7517b55ec3f99..51eed6d3e0736 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -10539,6 +10539,8 @@ self: super: with self; { safeio = callPackage ../development/python-modules/safeio { }; + safetensors = callPackage ../development/python-modules/safetensors { }; + safety = callPackage ../development/python-modules/safety { }; sagemaker = callPackage ../development/python-modules/sagemaker { }; |