Skip to content

Commit

Permalink
Expose linking flexibility for xz, gzip/deflate from libcramjam (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesgranger authored Sep 10, 2024
1 parent 6bfc928 commit 644c18d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 20 deletions.
42 changes: 27 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cramjam-python"
version = "2.8.4-rc3"
version = "2.8.4-rc4"
authors = ["Miles Granger <[email protected]>"]
edition = "2021"
license = "MIT"
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/experimental.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
25 changes: 20 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 644c18d

Please sign in to comment.