Package Details: python-safetensors 0.4.3-2

Git Clone URL: (read-only, click to copy)
Package Base: python-safetensors
Description: Simple, safe way to store and distribute tensors
Upstream URL:
Licenses: Apache
Submitter: Henry-ZHR
Maintainer: mane.andrea
Last Packager: mane.andrea
Votes: 3
Popularity: 0.61
First Submitted: 2023-01-08 09:54 (UTC)
Last Updated: 2024-04-17 17:56 (UTC)

Dependencies (27)

Sources (1)

Latest Comments

1 2 3 Next › Last »

mane.andrea commented on 2024-04-23 16:07 (UTC)

@hashworks I tried to build it in two different computers and in a clean chroot and I could not reproduce the issue. Is your system up-to-date? Can you try to build it in a clean chroot?

hashworks commented on 2024-04-21 17:08 (UTC)

I'm getting a test failure at tests/ saying RuntimeError: HIP error: shared object initialization failed. Can you reproduce that?

mane.andrea commented on 2024-04-17 17:57 (UTC)

@carsme Many thanks, I have patched it as you say

carsme commented on 2024-04-17 17:51 (UTC)

Two issues:

  • Re-building without cleaning the build directory fails due to the mkdir invocation.
  • Building with rustup instead of rust fails, due to that no toolchain version is specified.

These issues can be fixed by the following patch:

diff --git a/PKGBUILD b/PKGBUILD
index 03774ec..e069144 100644
@@ -39,11 +39,13 @@ source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz

 prepare() {
-  mkdir "safetensors-${pkgver}/.git"
+  mkdir -p "safetensors-${pkgver}/.git"

 build() {
   cd "safetensors-${pkgver}/bindings/python"
+  export RUSTUP_TOOLCHAIN=stable
   python -m build --wheel --no-isolation

mane.andrea commented on 2023-12-12 18:29 (UTC)

With @daskol patch now builds fine. I tried a chroot build in a machine with cuda and in a machine without cuda

mane.andrea commented on 2023-12-09 03:42 (UTC)

Sorry for the delay. I overlooked the notification. Will work on an updated PKGBUILD asap

daskol commented on 2023-12-09 02:41 (UTC)

In my optinion, the best solution is not put any .gitignore with glob pattern in AUR repo since there is no actual need in blacklisting files at all.

@h3ss I believe that it'd be better to create an empty directory .git at $srcdir/safetensors-$pkgver rather than patching or sed'ing (see ignore::WalkBuilder). Anyway, we should create an issue in PyO3/maturin. It is stupid that it traverses out of repo root. What about submodules? Why I should tweak include/ignore filters in pyproject.toml? Weird.

diff --git a/PKGBUILD b/PKGBUILD
index cb94dc8..4d04fcf 100644
@@ -38,6 +38,10 @@ checkdepends=('python-pytorch'

+prepare() {
+  mkdir "safetensors-${pkgver}/.git"
 build() {
   cd "safetensors-${pkgver}/bindings/python"
   python -m build --wheel --no-isolation

@xiota There is the same issue with python-tokenziers.

h3ss commented on 2023-12-05 03:34 (UTC)

The problem is that the AUR package includes a .gitignore file, and the maturin build backend will ignore anything specified in any .gitignore file in the path.

See: - Wheels for mixed Python/Rust project does not include Python source code #885

The contents of the AUR .gitignore are:


That first line is the problem, it basically excludes everything from inclusion (except what the Rust part of the build creates apparently).

I have been able to get around this by editing the src/safetensors-0.4.0/bindings/python/pyproject.toml file. Specifically, by adding this under the [tool.maturin] section:

include = ["**/*"]

See: - Maturin User Guide - Configuration - Specifically the include part

When this is done, the resulting .whl file reliably contains the needed Python source files.

So, how can we get around this in the PKGBUILD? By using sed to add the include line to the pyproject.toml in the build() function:

build() {
  cd "safetensors-${pkgver}/bindings/python"
  sed -i 's/\[tool.maturin\]/[tool.maturin]\ninclude = \["**\/*"\]/g' pyproject.toml
  python -m build --wheel --no-isolation

After adding that sed line, the package reliably passes all checks and builds.

@mane.andrea Can we get this or something equivalent incorporated into the PKGBUILD? I'm confident this should fix this longstanding issue.

PhotonX commented on 2023-11-26 18:14 (UTC) (edited on 2023-11-26 18:15 (UTC) by PhotonX)

I'm getting the check() errors as well. I don't understand what the underlying problem is, though. One of the errors is, exemlarily:

________________ ERROR collecting tests/ ________________
ImportError while importing test module '/home/photon/.cache/yay/python-safetensors/src/safetensors-0.4.0/bindings/python/tests/'.
Hint: make sure your test modules/packages have valid Python names.
/usr/lib/python3.11/importlib/ in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/ in <module>
    from safetensors import safe_open
E   ImportError: cannot import name 'safe_open' from 'safetensors' (unknown location)

So it searches for safe_open from... itself? I think, I have all the necessary dependencies installed, but none of them provides this...

t3nzor commented on 2023-11-20 02:22 (UTC) (edited on 2023-11-20 02:22 (UTC) by t3nzor)

The built package doesn't seem to install the Python bindings, only the shared library. I was able to work around this as follows:

makepkg -si --nocheck

sudo cp src/safetensors-0.4.0/bindings/python/py_src/safetensors/* /usr/lib/python3.11/site-packages/safetensors