Skip to content

Commit 9c75987

Browse files
committed
lzma: build the xz-core engine on wasm32
Expose `_lzma` on wasm32 and Android by compiling the xz-core engine on those targets instead of gating it out. Assisted-by: Claude
1 parent 55cebcd commit 9c75987

4 files changed

Lines changed: 3 additions & 13 deletions

File tree

crates/common/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ zlib-rs = { workspace = true, optional = true }
6666
lock_api = { workspace = true }
6767
siphasher = { workspace = true }
6868
num-complex = { workspace = true }
69-
70-
[target.'cfg(not(any(target_os = "android", target_arch = "wasm32")))'.dependencies]
71-
# RustPython does not expose `_lzma` on these targets; keep the native engine's
72-
# dependency boundary with its common-module owner rather than in stdlib.
7369
xz = { workspace = true, optional = true }
7470
xz-sys = { workspace = true, optional = true }
7571

crates/common/src/compression/lzma.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
//! VM-independent liblzma stream engine.
44
//!
5-
//! `_lzma` is not built on Android or WebAssembly in RustPython, so the xz
6-
//! dependency and this module have the same target boundary. Python object
7-
//! conversion and exception construction remain in `rustpython-stdlib`.
5+
//! Python object conversion and exception construction remain in
6+
//! `rustpython-stdlib`.
87
98
use xz::stream::{
109
Action, Check, Error as XzError, Filters, LzmaOptions, MatchFinder, Mode, Status, Stream,

crates/common/src/compression/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ impl<'a> Chunker<'a> {
7171

7272
#[cfg(feature = "bz2")]
7373
pub mod bz2;
74-
#[cfg(all(
75-
feature = "lzma",
76-
not(any(target_os = "android", target_arch = "wasm32"))
77-
))]
74+
#[cfg(feature = "lzma")]
7875
pub mod lzma;
7976
#[cfg(feature = "zlib")]
8077
pub mod zlib;

crates/stdlib/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ mod compression; // internal module
2323
mod contextvars;
2424
mod csv;
2525

26-
#[cfg(not(any(target_os = "android", target_arch = "wasm32")))]
2726
mod lzma;
2827

2928
mod zlib;
@@ -206,7 +205,6 @@ pub fn stdlib_module_defs(ctx: &Context) -> Vec<&'static builtins::PyModuleDef>
206205
not(any(target_os = "ios", target_arch = "wasm32"))
207206
))]
208207
locale::module_def(ctx),
209-
#[cfg(not(any(target_os = "android", target_arch = "wasm32")))]
210208
lzma::module_def(ctx),
211209
math::module_def(ctx),
212210
md5::module_def(ctx),

0 commit comments

Comments
 (0)