Skip to content

Commit

Permalink
Remove experimental codecs in default builds (#197)
Browse files Browse the repository at this point in the history
Removes experimental blosc2, igzip, ideflate, and izlib from default builds
Still available by building from source w/ features enabled.
  • Loading branch information
milesgranger authored Jan 4, 2025
1 parent fef3a9d commit 61564e7
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 84 deletions.
79 changes: 3 additions & 76 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,81 +88,21 @@ jobs:
with:
target: ${{ matrix.conf.target-triple }}

- name: Install nasm (Windows / Linux)
if: runner.os != 'macOS'
uses: ilammy/setup-nasm@v1

- name: Set MSVC developer prompt
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Setup (Mac)
if: runner.os == 'macOS'
run: |
brew install ninja automake autoconf coreutils libtool nasm
echo "MACOSX_DEPLOYMENT_TARGET=10.12" >> $GITHUB_ENV
- name: Setup (Windows)
if: runner.os == 'Windows'
uses: lukka/get-cmake@latest

- name: Setup (Linux)
if: runner.os == 'Linux'
env:
TARGET_TRIPLE: ${{ matrix.conf.target-triple }}
WORKSPACE: ${{ github.workspace }}
BLOSC2_INSTALL_PREFIX: ${{ github.workspace }}/blosc2
ISAL_INSTALL_PREFIX: ${{ github.workspace }}/isal
run: |
sudo apt update
sudo apt install ninja-build -y
echo "BLOSC2_INSTALL_PREFIX=$BLOSC2_INSTALL_PREFIX" >> $GITHUB_ENV
echo "ISAL_INSTALL_PREFIX=$ISAL_INSTALL_PREFIX" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$BLOSC2_INSTALL_PREFIX/lib:$BLOSC2_INSTALL_PREFIX/lib64:$ISAL_INSTALL_PREFIX/lib:$ISAL_INSTALL_PREFIX/lib64" >> $GITHUB_ENV
# so we'll just use 'cross' to build and pass it in for the action for all archs
# nothing special for the revision pin, just deterministic install
cargo install cross --git https://github.com/cross-rs/cross --rev 6d097fb
# Build blosc2
cross build --release --target $TARGET_TRIPLE --package blosc2-sys --target-dir build
blosc2_sys_dir=$(ls build/$TARGET_TRIPLE/release/build/ | grep blosc2-sys)
mv $WORKSPACE/build/$TARGET_TRIPLE/release/build/$blosc2_sys_dir/out $BLOSC2_INSTALL_PREFIX
tree -L 2 $BLOSC2_INSTALL_PREFIX
# Build isal only on 64-bit systems
# At the time of this writing, it technically builds for all unix 32-bit systems
# but ISA-L has explicitly stated they're dropping support.
if [[ "$TARGET_TRIPLE" == armv7* || "$TARGET_TRIPLE" == i686* ]]; then
echo "Not building ISA-L on 32 bit target"
mkdir -p $ISAL_INSTALL_PREFIX
else
cross build --release --target $TARGET_TRIPLE --package isal-sys --target-dir build
isal_sys_dir=$(ls build/$TARGET_TRIPLE/release/build/ | grep isal-sys)
mv $WORKSPACE/build/$TARGET_TRIPLE/release/build/$isal_sys_dir/out $ISAL_INSTALL_PREFIX
tree -L 2 $ISAL_INSTALL_PREFIX
fi
- name: Rust Tests
if: matrix.conf.target == 'x86_64' && !startsWith(matrix.python-version, 'pypy') && matrix.python-version == '3.12'
run: cargo test

- name: Build wheel (Linux)
if: runner.os == 'Linux'
- name: Build wheel (OSX - Linux)
if: runner.os != 'Windows'
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.conf.target }}
manylinux: ${{ matrix.conf.manylinux }}
docker-options: |
-e BLOSC2_INSTALL_PREFIX=${{ github.workspace }}/blosc2
-e ISAL_INSTALL_PREFIX=${{ github.workspace }}/isal
-e LD_LIBRARY_PATH=${{ github.workspace }}/blosc2/lib:${{ github.workspace }}/blosc2/lib64:${{ github.workspace }}/isal/lib:${{ github.workspace }}/isal/lib64
args: -i ${{ matrix.python-version }} --release --out dist --features use-system-blosc2-static --features use-system-isal-static
before-script-linux: |
ls -l $BLOSC2_INSTALL_PREFIX
ls -l $ISAL_INSTALL_PREFIX
args: -i ${{ matrix.python-version }} --release --out dist

- name: Build wheel (Windows)
if: runner.os == 'Windows'
Expand All @@ -171,19 +111,6 @@ jobs:
maturin build -i python --release --out wheels --target ${{ matrix.conf.target-triple }}
$file = Get-ChildItem -Path "wheels" | Select-Object -First 1
delvewheel repair -v "wheels\$($file.Name)" -w "dist"
- name: Build wheel (MacOS)
if: runner.os == 'macOS'
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.conf.target-triple }}
args: -i python --release --out dist

- name: Fix wheel (MacOS)
if: runner.os == 'macOS'
run: |
python -m pip install delocate
delocate-wheel -v dist/*.whl
- name: Install built wheel and Test (Native)
# TODO: I'm not sure but the actual collection of tests on windows using pypy3.10 takes forever and/or fails
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cramjam-python"
version = "2.9.1"
version = "2.10.0"
authors = ["Miles Granger <miles59923@gmail.com>"]
edition = "2021"
license = "MIT"
Expand All @@ -14,7 +14,9 @@ name = "cramjam"
crate-type = ["cdylib"]

[features]
default = ["extension-module", "snappy", "lz4", "bzip2", "brotli", "xz", "zstd", "gzip", "zlib", "deflate", "blosc2", "igzip", "ideflate", "izlib"]
default = ["extension-module", "snappy", "lz4", "bzip2", "brotli", "xz", "zstd", "gzip", "zlib", "deflate"]
experimental = ["blosc2", "igzip", "ideflate", "izlib"]

extension-module = ["pyo3/extension-module"]
generate-import-lib = ["pyo3/generate-import-lib"] # needed for Windows PyPy builds

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ Available algorithms:
- [X] Deflate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`cramjam.deflate`
- [X] ZSTD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`cramjam.zstd`
- [X] XZ / LZMA&nbsp;&nbsp;`cramjam.xz`


Experimental (Requires build from source enabling each feature):

- [X] Blosc2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`cramjam.experimental.blosc2`
- [X] ISA-L backend _(only on 64-bit targets)_
- [X] igzip&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`cramjam.experimental.igzip`
Expand Down
6 changes: 5 additions & 1 deletion benchmarks/test_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@


if hasattr(cramjam, "experimental") and not hasattr(cramjam, "blosc2"):
cramjam.blosc2 = cramjam.experimental.blosc2
if hasattr(cramjam.experimental, "blosc2"):
cramjam.blosc2 = cramjam.experimental.blosc2


class Bzip2CompressedFile:
Expand Down Expand Up @@ -73,6 +74,9 @@ def test_blosc2(benchmark, file, use_cramjam: bool):
"""
import blosc2

if not hasattr(cramjam, "blosc2"):
pytest.skip("blosc2 not built")

data = file.read_bytes()
if use_cramjam:
benchmark(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "cramjam"
version = "2.9.1"
version = "2.10.0"
keywords = ["compression", "decompression", "snappy", "zstd", "bz2", "gzip", "lz4", "brotli", "deflate", "blosc2"]
requires-python = ">=3.8"
license = { file = "LICENSE" }
Expand Down
13 changes: 10 additions & 3 deletions tests/test_blosc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
except ImportError:
pytest.skip("experimental module not built", allow_module_level=True)
else:
blosc2 = experimental.blosc2
if hasattr(experimental, "blosc2"):
blosc2 = experimental.blosc2
else:
pytest.skip(
"experimental module doesn't contain blosc2", allow_module_level=True
)


settings.register_profile("local", max_examples=10)
Expand All @@ -25,7 +30,7 @@
def variants(e):
for attr in dir(e):
# TODO: LastCodec, LastFilter, LastRegisteredCodec/Filter not supported
if not attr.startswith('_') and not attr.lower().startswith('last'):
if not attr.startswith("_") and not attr.lower().startswith("last"):
yield getattr(e, attr)


Expand All @@ -47,7 +52,9 @@ def test_roundtrip_chunk_into(data, codec, filter, clevel):
kwargs = dict(clevel=clevel, filter=filter, codec=codec)
nbytes_compressed = len(blosc2.compress_chunk(data, **kwargs))

compressed = np.empty(blosc2.max_compressed_len(len(data.tobytes())), dtype=np.uint8)
compressed = np.empty(
blosc2.max_compressed_len(len(data.tobytes())), dtype=np.uint8
)
nbytes = blosc2.compress_chunk_into(data, compressed, **kwargs)

decompressed = np.empty(len(data.tobytes()) * 2, dtype=np.uint8)
Expand Down

0 comments on commit 61564e7

Please # to comment.