mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
xz (#7756)
This commit is contained in:
1 parent
57d1695a63
commit
f43ae46738
4 files changed
+62
-54
No files matched your search
Generated
+32
-22
@@ -2148,26 +2148,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"
|
||||
@@ -3790,8 +3770,6 @@ dependencies = [
|
||||
"insta",
|
||||
"itertools 0.14.0",
|
||||
"libc",
|
||||
"liblzma",
|
||||
"liblzma-sys",
|
||||
"libsqlite3-sys",
|
||||
"libz-rs-sys",
|
||||
"mac_address",
|
||||
@@ -3845,6 +3823,8 @@ dependencies = [
|
||||
"x509-cert",
|
||||
"x509-parser",
|
||||
"xml",
|
||||
"xz",
|
||||
"xz-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5371,6 +5351,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"
|
||||
|
||||
+2
-2
@@ -244,8 +244,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"
|
||||
|
||||
@@ -129,8 +129,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 }
|
||||
|
||||
+26
-28
@@ -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]
|
||||
|
||||
Reference in new issue
Block a user