From 644c18dccf1d6853091a8e2ef38f94134785a1ba Mon Sep 17 00:00:00 2001 From: Miles Granger Date: Tue, 10 Sep 2024 12:16:00 +0200 Subject: [PATCH] Expose linking flexibility for xz, gzip/deflate from libcramjam (#175) --- Cargo.toml | 42 +++++++++++++++++++++++++++--------------- src/experimental.rs | 1 + src/lib.rs | 25 ++++++++++++++++++++----- 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dfea61ec..b6a73db6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cramjam-python" -version = "2.8.4-rc3" +version = "2.8.4-rc4" authors = ["Miles Granger "] edition = "2021" license = "MIT" @@ -13,26 +13,38 @@ name = "cramjam" crate-type = ["cdylib"] [features] -default = ["extension-module", "snappy", "lz4", "bzip2", "brotli", "xz", "zstd", "gzip", "deflate", "blosc2"] -extension-module = ["pyo3/extension-module"] -generate-import-lib = ["pyo3/generate-import-lib"] # needed for Windows PyPy builds - -snappy = ["libcramjam/snappy"] -lz4 = ["libcramjam/lz4"] -bzip2 = ["libcramjam/bzip2"] -brotli = ["libcramjam/brotli"] -xz = ["libcramjam/xz"] -zstd = ["libcramjam/zstd"] -gzip = ["libcramjam/gzip"] -deflate = ["libcramjam/deflate"] -blosc2 = ["libcramjam/blosc2"] +default = ["extension-module", "snappy", "lz4", "bzip2", "brotli", "xz", "zstd", "gzip", "deflate", "blosc2"] +extension-module = ["pyo3/extension-module"] +generate-import-lib = ["pyo3/generate-import-lib"] # needed for Windows PyPy builds + +snappy = ["libcramjam/snappy"] +lz4 = ["libcramjam/lz4"] +bzip2 = ["libcramjam/bzip2"] +brotli = ["libcramjam/brotli"] +zstd = ["libcramjam/zstd"] + +xz = ["xz-static"] +xz-static = ["libcramjam/xz-static"] +xz-shared = ["libcramjam/xz-shared"] + +gzip = ["gzip-static"] +gzip-static = ["libcramjam/gzip-static"] +gzip-shared = ["libcramjam/gzip-shared"] + +deflate = ["deflate-static"] +deflate-static = ["libcramjam/deflate-static"] +deflate-shared = ["libcramjam/deflate-shared"] + +blosc2 = ["blosc2-static"] +blosc2-static = ["libcramjam/blosc2-static"] +blosc2-shared = ["libcramjam/blosc2-shared"] use-system-blosc2-static = ["libcramjam/use-system-blosc2", "libcramjam/blosc2-static"] use-system-blosc2-shared = ["libcramjam/use-system-blosc2", "libcramjam/blosc2-shared"] [dependencies] pyo3 = { version = "^0.22", default-features = false, features = ["macros"] } -libcramjam = { version = "0.4.2", default-features = false } +libcramjam = { version = "0.4.5", default-features = false } [build-dependencies] pyo3-build-config = "^0.22" diff --git a/src/experimental.rs b/src/experimental.rs index 2ba12fe9..b47f69d1 100644 --- a/src/experimental.rs +++ b/src/experimental.rs @@ -9,6 +9,7 @@ use pyo3::prelude::*; #[pymodule] pub mod experimental { + #[cfg(any(feature = "blosc2", feature = "blosc2-static", feature = "blosc2-shared"))] #[pymodule_export] use crate::blosc2::blosc2; } diff --git a/src/lib.rs b/src/lib.rs index 5e85ceef..9adba54a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,19 +51,27 @@ //! b'some bytes here' //! ``` +pub mod exceptions; +pub mod experimental; +pub mod io; + +#[cfg(any(feature = "blosc2", feature = "blosc2-static", feature = "blosc2-shared"))] pub mod blosc2; +#[cfg(feature = "brotli")] pub mod brotli; +#[cfg(feature = "bzip2")] pub mod bzip2; +#[cfg(any(feature = "deflate", feature = "deflate-static", feature = "deflate-shared"))] pub mod deflate; -pub mod exceptions; - -pub mod experimental; - +#[cfg(any(feature = "gzip", feature = "gzip-static", feature = "gzip-shared"))] pub mod gzip; -pub mod io; +#[cfg(feature = "lz4")] pub mod lz4; +#[cfg(feature = "snappy")] pub mod snappy; +#[cfg(any(feature = "xz", feature = "xz-static", feature = "xz-shared"))] pub mod xz; +#[cfg(feature = "zstd")] pub mod zstd; use io::{PythonBuffer, RustyBuffer}; @@ -387,27 +395,34 @@ mod cramjam { #[pymodule_export] use crate::DecompressionError; + #[cfg(feature = "snappy")] #[pymodule_export] use crate::snappy::snappy; + #[cfg(feature = "zstd")] #[pymodule_export] use crate::zstd::zstd; + #[cfg(feature = "lz4")] #[pymodule_export] use crate::lz4::lz4; #[pymodule_export] use crate::brotli::brotli; + #[cfg(any(feature = "deflate", feature = "deflate-static", feature = "deflate-shared"))] #[pymodule_export] use crate::deflate::deflate; + #[cfg(any(feature = "xz", feature = "xz-static", feature = "xz-shared"))] #[pymodule_export] use crate::xz::xz; + #[cfg(feature = "bzip2")] #[pymodule_export] use crate::bzip2::bzip2; + #[cfg(any(feature = "gzip", feature = "gzip-static", feature = "gzip-shared"))] #[pymodule_export] use crate::gzip::gzip;