]> khamidou — GitHub mirrors - safetensors.git/commitdiff
Memory map as private pure copy. (#553)
authorNicolas Patry <patry.nicolas@protonmail.com>
Thu, 2 Jan 2025 17:07:11 +0000 (18:07 +0100)
committerGitHub <noreply@github.com>
Thu, 2 Jan 2025 17:07:11 +0000 (18:07 +0100)
bindings/python/Cargo.toml
bindings/python/src/lib.rs
flake.nix
safetensors/Cargo.toml

index 81923eb308cfc014eb6571a47d09e60f6820d6da..c963fd643218a834ff727a069b7770baddc8144a 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name = "safetensors-python"
-version = "0.5.0-dev.0"
+version = "0.5.1-dev.0"
 edition = "2021"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
index ecd318c73049a3cc80484b8a5500344841cc4159..21062bd433428a0f1a6e9df6ff45f5ae6edfa5bd 100644 (file)
@@ -406,7 +406,7 @@ impl Open {
 
         // SAFETY: Mmap is used to prevent allocating in Rust
         // before making a copy within Python.
-        let buffer = unsafe { MmapOptions::new().map(&file)? };
+        let buffer = unsafe { MmapOptions::new().map_copy_read_only(&file)? };
 
         let (n, metadata) = SafeTensors::read_metadata(&buffer).map_err(|e| {
             SafetensorError::new_err(format!("Error while deserializing header: {e:?}"))
index 5711a08efc673a16c93bee35471d47d7b9f4ee05..d9effbaf0dd210a4ec38c7033ff07818ae9510d8 100644 (file)
--- a/flake.nix
+++ b/flake.nix
@@ -32,6 +32,7 @@
             postShellHook = ''
               unset SOURCE_DATE_EPOCH
             '';
+            LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${pkgs.stdenv.cc.cc.lib}/lib";
           };
 
         }
index b2d20b8ec932cdd5787c179fe38bd3e3b2d34dfd..d59a6e186c093e9d5cf650fdc2cafbbc1f72a74c 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name = "safetensors"
-version = "0.5.0-dev.0"
+version = "0.5.1-dev.0"
 edition = "2021"
 homepage = "https://github.com/huggingface/safetensors"
 repository = "https://github.com/huggingface/safetensors"