Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More work on LZMA / XZ support #133

Merged
merged 14 commits into from
Mar 9, 2024
27 changes: 13 additions & 14 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jobs:
args: -i python --release --out dist --sdist --manifest-path cramjam-python/Cargo.toml
- name: Install built wheels - x86_64
run: |
pip install cramjam --no-index --find-links dist --force-reinstall
pip install cramjam-cli --no-index --find-links dist --force-reinstall
pip install cramjam --pre --no-index --find-links dist --force-reinstall
pip install cramjam-cli --pre --no-index --find-links dist --force-reinstall
- name: Build wheels - universal2
if: ${{ matrix.python-version >= '3.8' || contains(fromJson('["3.10", "3.11", "3.12"]'), matrix.python-version) }}
uses: PyO3/maturin-action@v1
Expand All @@ -55,8 +55,8 @@ jobs:
- name: Install built wheels - universal2
if: ${{ matrix.python-version >= '3.8' || contains(fromJson('["3.10", "3.11", "3.12"]'), matrix.python-version) }}
run: |
pip install cramjam --no-index --find-links dist --force-reinstall
pip install cramjam-cli --no-index --find-links dist --force-reinstall
pip install cramjam --pre --no-index --find-links dist --force-reinstall
pip install cramjam-cli --pre --no-index --find-links dist --force-reinstall
- name: Python UnitTest - cramjam-cli
run: |
pip install pytest numpy hypothesis
Expand Down Expand Up @@ -101,8 +101,8 @@ jobs:
args: -i python --release --out dist --manifest-path cramjam-cli/Cargo.toml
- name: Install built wheel
run: |
pip install cramjam-cli --no-index --find-links dist --force-reinstall
pip install cramjam[dev] --find-links dist --force-reinstall
pip install cramjam-cli --pre --no-index --find-links dist --force-reinstall
pip install cramjam[dev] --pre --find-links dist --force-reinstall
- name: Python UnitTest - cramjam-python
run: |
python -m pytest cramjam-python -vs --ignore cramjam-python\benchmarks
Expand Down Expand Up @@ -149,12 +149,12 @@ jobs:
- name: Python UnitTest - cramjam-python
if: matrix.target == 'x86_64'
run: |
pip install cramjam[dev] --find-links dist --force-reinstall
pip install cramjam[dev] --pre --find-links dist --force-reinstall
python -m pytest cramjam-python -vs --ignore **/benchmarks
- name: Python UnitTest - cramjam-cli
if: matrix.target == 'x86_64'
run: |
pip install cramjam-cli --no-index --find-links dist --force-reinstall
pip install cramjam-cli --pre --no-index --find-links dist --force-reinstall
python -m pytest cramjam-cli -vs --ignore **/benchmarks
- name: Upload wheels
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -217,8 +217,8 @@ jobs:
PYTHON=python${{ matrix.python }}
$PYTHON -m venv venv
venv/bin/pip install -U pip
venv/bin/pip install cramjam --no-index --find-links /artifacts --force-reinstall
venv/bin/pip install cramjam-cli --no-index --find-links /artifacts --force-reinstall
venv/bin/pip install cramjam --pre --no-index --find-links /artifacts --force-reinstall
venv/bin/pip install cramjam-cli --pre --no-index --find-links /artifacts --force-reinstall
venv/bin/python -c 'import cramjam'
venv/bin/cramjam-cli --help
- name: Upload wheels
Expand Down Expand Up @@ -264,13 +264,12 @@ jobs:
# TODO: I'm not sure but the actual collection of tests on windows using pypy3.10 takes forever and/or fails
if: ${{ matrix.python != 'pypy-3.10' && matrix.platform.os != 'windows-latest' }}
run: |
pip install cramjam[dev] --find-links dist --force-reinstall
cd cramjam-python
python -m pytest tests -v
pip install cramjam[dev] --pre --find-links dist --force-reinstall
python -m pytest cramjam-python -vs --ignore **/benchmarks
- name: cramjam-cli test
if: ${{ matrix.platform.os != 'windows-latest' }}
run: |
pip install cramjam-cli --no-index --find-links dist --force-reinstall
pip install cramjam-cli --pre --no-index --find-links dist --force-reinstall
cd cramjam-cli
cramjam-cli --help
- name: Upload wheels
Expand Down
59 changes: 43 additions & 16 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions cramjam-python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cramjam-python"
version = "2.8.3"
version = "2.8.3-rc1"
authors = ["Miles Granger <[email protected]>"]
edition = "2021"
license = "MIT"
Expand All @@ -17,10 +17,9 @@ default = ["extension-module"]
extension-module = ["pyo3/extension-module"]
generate-import-lib = ["pyo3/generate-import-lib"] # needed for Windows PyPy builds


[dependencies]
pyo3 = { version = "^0.20", default-features = false, features = ["macros"] }
libcramjam = "0.2.0"
libcramjam = { version = "^0.3" }

[build-dependencies]
pyo3-build-config = "^0.20"
16 changes: 8 additions & 8 deletions cramjam-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ Some basic benchmarks are available [in the benchmarks directory](./benchmarks/R

Available algorithms:

- [X] Snappy
- [X] Brotli
- [X] Bzip2
- [X] Lz4
- [X] Gzip
- [X] Deflate
- [X] ZSTD
- [X] LZMA / XZ (cramjam.experimental.lzma) # experimental support!
- [X] Snappy (cramjam.snappy)
- [X] Brotli (cramjam.brotli)
- [X] Bzip2 (cramjam.bzip2)
- [X] Lz4 (cramjam.lz4)
- [X] Gzip (cramjam.gzip)
- [X] Deflate (cramjam.deflate)
- [X] ZSTD (cramjam.zstd)
- [X] XZ / LZMA (cramjam.xz)

All available for use as:

Expand Down
11 changes: 3 additions & 8 deletions cramjam-python/src/brotli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,14 @@ pub fn decompress(py: Python, data: BytesType, output_len: Option<usize>) -> PyR
/// ```
#[pyfunction]
pub fn compress(py: Python, data: BytesType, level: Option<u32>, output_len: Option<usize>) -> PyResult<RustyBuffer> {
crate::generic!(
py,
libcramjam::brotli::compress[data],
output_len = output_len,
level = level
)
.map_err(CompressionError::from_err)
crate::generic!(py, libcramjam::brotli::compress[data], output_len = output_len, level)
.map_err(CompressionError::from_err)
}

/// Compress directly into an output buffer
#[pyfunction]
pub fn compress_into(py: Python, input: BytesType, mut output: BytesType, level: Option<u32>) -> PyResult<usize> {
crate::generic!(py, libcramjam::brotli::compress[input, output], level=level).map_err(CompressionError::from_err)
crate::generic!(py, libcramjam::brotli::compress[input, output], level).map_err(CompressionError::from_err)
}

/// Decompress directly into an output buffer
Expand Down
11 changes: 3 additions & 8 deletions cramjam-python/src/bzip2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,14 @@ pub fn decompress(py: Python, data: BytesType, output_len: Option<usize>) -> PyR
/// ```
#[pyfunction]
pub fn compress(py: Python, data: BytesType, level: Option<u32>, output_len: Option<usize>) -> PyResult<RustyBuffer> {
crate::generic!(
py,
libcramjam::bzip2::compress[data],
output_len = output_len,
level = level
)
.map_err(CompressionError::from_err)
crate::generic!(py, libcramjam::bzip2::compress[data], output_len = output_len, level)
.map_err(CompressionError::from_err)
}

/// Compress directly into an output buffer
#[pyfunction]
pub fn compress_into(py: Python, input: BytesType, mut output: BytesType, level: Option<u32>) -> PyResult<usize> {
crate::generic!(py, libcramjam::bzip2::compress[input, output], level = level).map_err(CompressionError::from_err)
crate::generic!(py, libcramjam::bzip2::compress[input, output], level).map_err(CompressionError::from_err)
}

/// Decompress directly into an output buffer
Expand Down
11 changes: 3 additions & 8 deletions cramjam-python/src/deflate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,14 @@ pub fn decompress(py: Python, data: BytesType, output_len: Option<usize>) -> PyR
/// ```
#[pyfunction]
pub fn compress(py: Python, data: BytesType, level: Option<u32>, output_len: Option<usize>) -> PyResult<RustyBuffer> {
crate::generic!(
py,
libcramjam::deflate::compress[data],
output_len = output_len,
level = level
)
.map_err(CompressionError::from_err)
crate::generic!(py, libcramjam::deflate::compress[data], output_len = output_len, level)
.map_err(CompressionError::from_err)
}

/// Compress directly into an output buffer
#[pyfunction]
pub fn compress_into(py: Python, input: BytesType, mut output: BytesType, level: Option<u32>) -> PyResult<usize> {
crate::generic!(py, libcramjam::deflate::compress[input, output], level = level).map_err(CompressionError::from_err)
crate::generic!(py, libcramjam::deflate::compress[input, output], level).map_err(CompressionError::from_err)
}

/// Decompress directly into an output buffer
Expand Down
Loading
Loading