diff --git a/Cargo.lock b/Cargo.lock index e388302e489..54ec1bf014e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2140,26 +2140,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "liblzma" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6033b77c21d1f56deeae8014eb9fbe7bdf1765185a6c508b5ca82eeaed7f899" -dependencies = [ - "liblzma-sys", -] - -[[package]] -name = "liblzma-sys" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a60851d15cd8c5346eca4ab8babff585be2ae4bc8097c067291d3ffe2add3b6" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - [[package]] name = "libm" version = "0.2.16" @@ -3772,8 +3752,6 @@ dependencies = [ "insta", "itertools 0.14.0", "libc", - "liblzma", - "liblzma-sys", "libsqlite3-sys", "libz-rs-sys", "mac_address", @@ -3826,6 +3804,8 @@ dependencies = [ "x509-cert", "x509-parser", "xml", + "xz", + "xz-sys", ] [[package]] @@ -5345,6 +5325,36 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8aa498d22c9bbaf482329839bc5620c46be275a19a812e9a22a2b07529a642a" +[[package]] +name = "xz" +version = "0.4.6-rc.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7af8851c229f574c5e4f4e9b6d90ca06c43974a563f7f42de4b88d651bf8f19c" +dependencies = [ + "xz-core", +] + +[[package]] +name = "xz-core" +version = "0.1.0-rc.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef4d12cf9c122b2523cce22d6ab3083f4eb56d1221e5d30ddcc70fbaac553589" +dependencies = [ + "libc", + "memchr", + "windows-sys 0.61.2", +] + +[[package]] +name = "xz-sys" +version = "0.4.6-rc.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "114e3a14e5bb2d46513305741650595041b7e7e1677aa5c9715a09b7a8da08fd" +dependencies = [ + "libc", + "xz-core", +] + [[package]] name = "yoke" version = "0.8.2" diff --git a/Cargo.toml b/Cargo.toml index de2704842c3..0cd2b122cbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -236,8 +236,8 @@ lexical-parse-float = "1.0.6" libc = "0.2.186" libffi = "5" libloading = "0.9" -liblzma = "0.4" -liblzma-sys = "0.4" +xz = "0.4.6-rc.0" +xz-sys = "0.4.6-rc.0" libsqlite3-sys = "0.37" libz-rs-sys = "0.6" lock_api = "0.4" diff --git a/crates/stdlib/Cargo.toml b/crates/stdlib/Cargo.toml index 4547368322d..3233f17db9e 100644 --- a/crates/stdlib/Cargo.toml +++ b/crates/stdlib/Cargo.toml @@ -128,8 +128,8 @@ pkcs8 = { workspace = true, features = ["encryption", "pkcs5", "pem"], optional [target.'cfg(not(any(target_os = "android", target_arch = "wasm32")))'.dependencies] libsqlite3-sys = { workspace = true, features = ["bundled"], optional = true } -liblzma = { workspace = true } -liblzma-sys = { workspace = true } +xz = { workspace = true } +xz-sys = { workspace = true } [target.'cfg(windows)'.dependencies] paste = { workspace = true } diff --git a/crates/stdlib/src/lzma.rs b/crates/stdlib/src/lzma.rs index 7abfc97251a..0b699baddbb 100644 --- a/crates/stdlib/src/lzma.rs +++ b/crates/stdlib/src/lzma.rs @@ -9,14 +9,20 @@ mod _lzma { DecompressError, DecompressState, DecompressStatus, Decompressor, }; use alloc::fmt; - use liblzma::stream::{ + use xz::stream::{ Action, Check, Error, Filters, LzmaOptions, MatchFinder, Mode, Status, Stream, TELL_ANY_CHECK, TELL_NO_CHECK, }; // lzma_check, lzma_mode, lzma_match_finder have platform-dependent signedness // (i32 on Windows, u32 elsewhere). Define as fixed-type const to avoid mismatch. + use rustpython_common::lock::PyMutex; + use rustpython_vm::builtins::{PyBaseExceptionRef, PyBytesRef, PyDict, PyType, PyTypeRef}; + use rustpython_vm::convert::ToPyException; + use rustpython_vm::function::ArgBytesLike; + use rustpython_vm::types::Constructor; + use rustpython_vm::{Py, PyObjectRef, PyPayload, PyResult, VirtualMachine}; #[pyattr] - use liblzma_sys::{ + use xz_sys::{ LZMA_FILTER_ARM as FILTER_ARM, LZMA_FILTER_ARMTHUMB as FILTER_ARMTHUMB, LZMA_FILTER_DELTA as FILTER_DELTA, LZMA_FILTER_IA64 as FILTER_IA64, LZMA_FILTER_LZMA1 as FILTER_LZMA1, LZMA_FILTER_LZMA2 as FILTER_LZMA2, @@ -24,47 +30,39 @@ mod _lzma { LZMA_FILTER_X86 as FILTER_X86, }; #[pyattr] - use liblzma_sys::{ - LZMA_PRESET_DEFAULT as PRESET_DEFAULT, LZMA_PRESET_EXTREME as PRESET_EXTREME, - }; - use rustpython_common::lock::PyMutex; - use rustpython_vm::builtins::{PyBaseExceptionRef, PyBytesRef, PyDict, PyType, PyTypeRef}; - use rustpython_vm::convert::ToPyException; - use rustpython_vm::function::ArgBytesLike; - use rustpython_vm::types::Constructor; - use rustpython_vm::{Py, PyObjectRef, PyPayload, PyResult, VirtualMachine}; + use xz_sys::{LZMA_PRESET_DEFAULT as PRESET_DEFAULT, LZMA_PRESET_EXTREME as PRESET_EXTREME}; const BUFSIZ: usize = 8192; - // liblzma_sys enum types have platform-dependent signedness; `as _` normalizes to i32 + // xz_sys enum types have platform-dependent signedness; `as _` normalizes to i32 #[pyattr] - const CHECK_NONE: i32 = liblzma_sys::LZMA_CHECK_NONE as _; + const CHECK_NONE: i32 = xz_sys::LZMA_CHECK_NONE as _; #[pyattr] - const CHECK_CRC32: i32 = liblzma_sys::LZMA_CHECK_CRC32 as _; + const CHECK_CRC32: i32 = xz_sys::LZMA_CHECK_CRC32 as _; #[pyattr] - const CHECK_CRC64: i32 = liblzma_sys::LZMA_CHECK_CRC64 as _; + const CHECK_CRC64: i32 = xz_sys::LZMA_CHECK_CRC64 as _; #[pyattr] - const CHECK_SHA256: i32 = liblzma_sys::LZMA_CHECK_SHA256 as _; + const CHECK_SHA256: i32 = xz_sys::LZMA_CHECK_SHA256 as _; #[pyattr] const CHECK_ID_MAX: i32 = 15; #[pyattr] const CHECK_UNKNOWN: i32 = CHECK_ID_MAX + 1; #[pyattr] - const MF_HC3: i32 = liblzma_sys::LZMA_MF_HC3 as _; + const MF_HC3: i32 = xz_sys::LZMA_MF_HC3 as _; #[pyattr] - const MF_HC4: i32 = liblzma_sys::LZMA_MF_HC4 as _; + const MF_HC4: i32 = xz_sys::LZMA_MF_HC4 as _; #[pyattr] - const MF_BT2: i32 = liblzma_sys::LZMA_MF_BT2 as _; + const MF_BT2: i32 = xz_sys::LZMA_MF_BT2 as _; #[pyattr] - const MF_BT3: i32 = liblzma_sys::LZMA_MF_BT3 as _; + const MF_BT3: i32 = xz_sys::LZMA_MF_BT3 as _; #[pyattr] - const MF_BT4: i32 = liblzma_sys::LZMA_MF_BT4 as _; + const MF_BT4: i32 = xz_sys::LZMA_MF_BT4 as _; #[pyattr] - const MODE_FAST: i32 = liblzma_sys::LZMA_MODE_FAST as _; + const MODE_FAST: i32 = xz_sys::LZMA_MODE_FAST as _; #[pyattr] - const MODE_NORMAL: i32 = liblzma_sys::LZMA_MODE_NORMAL as _; + const MODE_NORMAL: i32 = xz_sys::LZMA_MODE_NORMAL as _; enum Format { Auto = 0, @@ -385,13 +383,13 @@ mod _lzma { Ok(filters) } - const DEFAULT_LC: u32 = liblzma_sys::LZMA_LC_DEFAULT; - const DEFAULT_LP: u32 = liblzma_sys::LZMA_LP_DEFAULT; - const DEFAULT_PB: u32 = liblzma_sys::LZMA_PB_DEFAULT; + const DEFAULT_LC: u32 = xz_sys::LZMA_LC_DEFAULT; + const DEFAULT_LP: u32 = xz_sys::LZMA_LP_DEFAULT; + const DEFAULT_PB: u32 = xz_sys::LZMA_PB_DEFAULT; const DICT_POW2: [u8; 10] = [18, 20, 21, 22, 22, 23, 23, 24, 25, 26]; fn preset_dict_size(preset: u32) -> u32 { - let level = (preset & liblzma_sys::LZMA_PRESET_LEVEL_MASK) as usize; + let level = (preset & xz_sys::LZMA_PRESET_LEVEL_MASK) as usize; if level > 9 { return 0; } @@ -493,7 +491,7 @@ mod _lzma { #[pyfunction] fn is_check_supported(check_id: i32) -> bool { - unsafe { liblzma_sys::lzma_check_is_supported(check_id as _) != 0 } + unsafe { xz_sys::lzma_check_is_supported(check_id as _) != 0 } } #[pyfunction]