]> khamidou — GitHub mirrors - safetensors.git/commitdiff
Making py311 the default. (#589)
authorNicolas Patry <patry.nicolas@protonmail.com>
Mon, 17 Mar 2025 09:26:58 +0000 (10:26 +0100)
committerGitHub <noreply@github.com>
Mon, 17 Mar 2025 09:26:58 +0000 (10:26 +0100)
* Making py311 the default.

* Fixing release script.

* No default features everywhere.

.github/workflows/python-bench.yml
.github/workflows/python-release.yml
.github/workflows/python.yml
.pre-commit-config.yaml
bindings/python/Cargo.toml
bindings/python/src/lib.rs
flake.nix

index 7bd81ec1b98e23816fc2b540b52c1fedbe03e8f3..cbfd62de268d05729d9cf3508636dd7fb85ccb47 100644 (file)
@@ -16,8 +16,6 @@ jobs:
   benchmark:
     name: Performance regression check
     runs-on: ubuntu-latest
-    env: 
-      MATURIN_PEP517_ARGS: "--features py311,pyo3/extension-module"
     steps:
       - uses: actions/checkout@v4
       - name: Install Rust
index 9399909be25a53390b338318157282147e599d75..58c8efca609820ae5753c3f219df657d92992bab 100644 (file)
@@ -46,7 +46,7 @@ jobs:
         uses: PyO3/maturin-action@v1
         with:
           target: ${{ matrix.platform.target }}
-          args: --release --out dist --manifest-path bindings/python/Cargo.toml --features pyo3/extension-module,${{ matrix.pyfeature }}
+          args: --release --out dist --manifest-path bindings/python/Cargo.toml --features pyo3/extension-module,${{ matrix.pyfeature }} --no-default-features
           sccache: 'true'
           manylinux: auto
       - name: Upload wheels
@@ -78,7 +78,7 @@ jobs:
         uses: PyO3/maturin-action@v1
         with:
           target: ${{ matrix.platform.target }}
-          args: --release --out dist --manifest-path bindings/python/Cargo.toml --features pyo3/extension-module,${{ matrix.pyfeature }}
+          args: --release --out dist --manifest-path bindings/python/Cargo.toml --features pyo3/extension-module,${{ matrix.pyfeature }} --no-default-features
           sccache: 'true'
           manylinux: musllinux_1_2
       - name: Upload wheels
@@ -107,7 +107,7 @@ jobs:
         uses: PyO3/maturin-action@v1
         with:
           target: ${{ matrix.platform.target }}
-          args: --release --out dist --manifest-path bindings/python/Cargo.toml --features pyo3/extension-module,${{ matrix.pyfeature }}
+          args: --release --out dist --manifest-path bindings/python/Cargo.toml --features pyo3/extension-module,${{ matrix.pyfeature }} --no-default-features
           sccache: 'true'
       - name: Upload wheels
         uses: actions/upload-artifact@v4
@@ -134,7 +134,7 @@ jobs:
         uses: PyO3/maturin-action@v1
         with:
           target: ${{ matrix.platform.target }}
-          args: --release --out dist --manifest-path bindings/python/Cargo.toml --features pyo3/extension-module,${{ matrix.pyfeature }}
+          args: --release --out dist --manifest-path bindings/python/Cargo.toml --features pyo3/extension-module,${{ matrix.pyfeature }} --no-default-features
           sccache: 'true'
       - name: Upload wheels
         uses: actions/upload-artifact@v4
index 0c5437c7d7a277c10645e534d9d74e4e41d044bf..0b9dd32fe15a385bb6674de3b16641c085284ead 100644 (file)
@@ -8,7 +8,7 @@ jobs:
     name: Check everything builds & tests
     runs-on: ${{ matrix.os }}
     env: 
-      MATURIN_PEP517_ARGS: "--features ${{ matrix.version.pyfeature }},pyo3/extension-module"
+      MATURIN_PEP517_ARGS: "--no-default-features --features ${{ matrix.version.pyfeature }},pyo3/extension-module"
     strategy:
       matrix:
         os: [ubuntu-latest, macos-13, windows-latest]
@@ -55,7 +55,7 @@ jobs:
 
       - name: Lint with Clippy
         run: | 
-          cargo clippy --features ${{ matrix.version.pyfeature }} -- -D warnings
+          cargo clippy --features ${{ matrix.version.pyfeature }} --no-default-features -- -D warnings
 
       - name: Run Audit
         run: cargo audit -D warnings
@@ -84,7 +84,7 @@ jobs:
 
       - name: Run tests
         run: |
-          cargo test --features ${{ matrix.version.pyfeature }}
+          cargo test --features ${{ matrix.version.pyfeature }} --no-default-features
           pip install .[testing]
           pytest -sv tests/
 
index a323e52ce36e2b113dc75864eae2caa62c22ccc5..1a28594bf50122930ff80429a2661f0924223348 100644 (file)
@@ -27,8 +27,6 @@ repos:
           [
             "--manifest-path",
             "bindings/python/Cargo.toml",
-            "--features",
-            "py311",
             "--all-targets",
             "--",
             "-Dwarnings",
index fe8bbf441054eb7478d925bd5b73cb29c83bc546..4052b9d4e45ff1a699146cb88cc205c448d703ca 100644 (file)
@@ -12,6 +12,7 @@ crate-type = ["cdylib"]
 [features]
 py38 = ["pyo3/abi3-py38"]
 py311 = ["pyo3/abi3-py311"]
+default = ["py311"]
 
 [dependencies]
 pyo3 = { version = "0.23", features = ["abi3"] }
index b6a0f49c16dc0bf06ae3980188f0d7dec474787e..6a654ada88403cf2a9247de532a103ed571e82c7 100644 (file)
@@ -28,11 +28,9 @@ static FLAX_MODULE: GILOnceCell<Py<PyModule>> = GILOnceCell::new();
 static MLX_MODULE: GILOnceCell<Py<PyModule>> = GILOnceCell::new();
 
 #[cfg(not(any(feature = "py38", feature = "py311")))]
-compile_error!(
-    "At least one python version must be enabled, use `maturin develop --features py311,pyo3/extension-module`"
-);
+compile_error!("At least one python version must be enabled, use `maturin develop` for python 3.11, `maturin develop --features py38,pyo3/extension-module --no-default-features` for python 3.8");
 #[cfg(all(feature = "py38", feature = "py311"))]
-compile_error!("Only one python version must be enabled");
+compile_error!("Only one python version must be enabled, make sure to deactivate default features for python <3.11");
 
 /// Serializes raw data.
 ///
index a0cba1b7cd57b6cdb0878f6bb03020b0d9bb8428..106f129a0d2fa359f34f52fe8b7b898cdb6fb19a 100644 (file)
--- a/flake.nix
+++ b/flake.nix
@@ -32,7 +32,7 @@
             postShellHook = ''
               unset SOURCE_DATE_EPOCH
             '';
-            LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.zlib}/lib";
+            LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.zlib}/lib:/run/opengl-driver/lib";
           };
 
         }