From da9c98675bca5a24d160ca3cc456ee7ebbd5c204 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Fri, 5 Aug 2022 04:00:51 +0900 Subject: [PATCH] optional bz2 --- Cargo.toml | 1 + stdlib/Cargo.toml | 3 ++- stdlib/src/lib.rs | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d584879f0..238cbe32c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ jit = ["rustpython-vm/jit"] threading = ["rustpython-vm/threading", "rustpython-stdlib/threading"] pylib = ["rustpython-vm/pylib"] zlib = ["stdlib", "rustpython-stdlib/zlib"] +bz2 = ["stdlib", "rustpython-stdlib/bz2"] ssl = ["rustpython-stdlib/ssl"] ssl-vendor = ["rustpython-stdlib/ssl-vendor"] diff --git a/stdlib/Cargo.toml b/stdlib/Cargo.toml index 91c3cd764..1a5e3555f 100644 --- a/stdlib/Cargo.toml +++ b/stdlib/Cargo.toml @@ -41,7 +41,7 @@ unic-ucd-ident = "0.9.0" adler32 = "1.2.0" crc32fast = "1.3.2" flate2 = "1.0.23" -bzip2 = "0.4" +bzip2 = { version = "0.4", optional = true } num-complex = "0.4.0" num-bigint = "0.4.3" @@ -86,6 +86,7 @@ compiler = ["rustpython-vm/compiler"] # parser = ["rustpython-parser", "ast"] zlib = ["libz-sys", "flate2/zlib"] +bz2 = ["bzip2"] ssl = ["openssl", "openssl-sys", "foreign-types-shared"] ssl-vendor = ["ssl", "openssl/vendored", "openssl-probe"] diff --git a/stdlib/src/lib.rs b/stdlib/src/lib.rs index e610e0059..7ba884549 100644 --- a/stdlib/src/lib.rs +++ b/stdlib/src/lib.rs @@ -25,7 +25,7 @@ mod random; mod statistics; // TODO: maybe make this an extension module, if we ever get those // mod re; -#[cfg(not(any(target_arch = "wasm32")))] +#[cfg(feature = "bz2")] mod bz2; #[cfg(not(target_arch = "wasm32"))] pub mod socket; @@ -117,12 +117,15 @@ pub fn get_module_inits() -> impl Iterator, StdlibInit "select" => select::make_module, "_socket" => socket::make_module, "faulthandler" => faulthandler::make_module, - "_bz2" => bz2::make_module, } #[cfg(feature = "ssl")] { "_ssl" => ssl::make_module, } + #[cfg(feature = "bz2")] + { + "_bz2" => bz2::make_module, + } // Unix-only #[cfg(unix)] {