Skip to content

Commit

Permalink
Use different lzma crate without liblzma-dev dependency (#778)
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhaus authored Jan 24, 2025
1 parent c6c4bdf commit 48ca536
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 44 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ jobs:
cache-dependency-glob: "uv.lock"
cache-local-path: ${{ env.UV_CACHE_DIR }}

- name: Install additional OS dependencies
run: |
sudo apt-get update
sudo apt-get -y install \
pkg-config \
liblzma-dev
- name: 🏗 Install the project
run: uv sync --locked --group lint

Expand Down Expand Up @@ -67,13 +60,6 @@ jobs:
cache-local-path: ${{ env.UV_CACHE_DIR }}
python-version: ${{ matrix.python-version }}

- name: Install additional OS dependencies
run: |
sudo apt-get update
sudo apt-get -y install \
pkg-config \
liblzma-dev
- name: 🏗 Install the project
run: uv sync --locked --group test

Expand Down Expand Up @@ -106,13 +92,6 @@ jobs:
with:
python-version-file: ".python-version"

- name: Install additional OS dependencies
run: |
sudo apt-get update
sudo apt-get -y install \
pkg-config \
liblzma-dev
- name: 🏗 Install the project
run: |
uv export --group benchmark > requirements.txt
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ jobs:
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Install additional OS dependencies
run: |
sudo apt-get update
sudo apt-get -y install \
pkg-config \
liblzma-dev
- name: 🏗 Set package version
run: |
sed -i "s/^version = \".*\"/version = \"${{ github.event.release.tag_name }}\"/" pyproject.toml
Expand Down
58 changes: 44 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ crate-type = ["cdylib"]
[dependencies]
base64 = "0.22.1"
byteorder = "1.5.0"
liblzma = "0.3.5"
pyo3 = "0.23.3"
rust-lzma = "0.6.0"
1 change: 0 additions & 1 deletion scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ curl -LsSf https://astral.sh/uv/install.sh | sh

# Install required packages for rust-lzma
sudo apt update
sudo apt install -y pkg-config liblzma-dev

# Install project dependencies
uv sync --frozen --group dev
Expand Down
11 changes: 10 additions & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::error::Error;
use std::io::{Cursor, Read};

use base64::{engine::general_purpose, Engine as _};
use liblzma::read::XzDecoder;
use liblzma::stream::Stream;
use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;

Expand All @@ -15,7 +18,13 @@ pub fn decompress_7z_base64_data(value: String) -> Result<Vec<u8>, Box<dyn Error
bytes.insert(8, 0);
}

Ok(lzma::decompress(&bytes)?)
let source = Cursor::new(&bytes);
let stream = Stream::new_lzma_decoder(u64::MAX)?;
let mut r = XzDecoder::new_stream(source, stream);
let mut result = Vec::new();
r.read_to_end(&mut result)?;

Ok(result)
}

/// Decompress base64 decoded 7z compressed string.
Expand Down

0 comments on commit 48ca536

Please sign in to comment.