diff --git a/README.md b/README.md index 3192e06..ad30b22 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,17 @@ Information on the supported Python versions can be found in the Getting Started pip install dissect.squashfs ``` -This module is also automatically installed if you install the `dissect` package. +This project decompresses lzo and lz4 compressed file systems and can use the faster, native (C-based) lz4 and lzo +implementations when installed, instead of the slower pure Python implementation provided by `dissect.util`. To use +these faster implementations, install the package with the lzo and lz4 extras: + +```bash +pip install "dissect.squashfs[lz4,lzo]" +``` + +Unfortunately there is no binary python-lzo wheel for PyPy installations on Windows, so it won't be installed there + +This module including the lz4 and lzo extras is also automatically installed if you install the `dissect` package. ## Build and test instructions diff --git a/dissect/squashfs/compression.py b/dissect/squashfs/compression.py index 4eb4fae..762f113 100644 --- a/dissect/squashfs/compression.py +++ b/dissect/squashfs/compression.py @@ -11,9 +11,9 @@ def initialize(id: int, options: Optional[bytes]) -> Compression: modules = { c_squashfs.ZLIB_COMPRESSION: (NativeZlib,), c_squashfs.LZMA_COMPRESSION: (NativeLZMA,), - c_squashfs.LZO_COMPRESSION: (NativeLZO, PythonLZO), + c_squashfs.LZO_COMPRESSION: (AvailableLZO,), c_squashfs.XZ_COMPRESSION: (NativeXZ,), - c_squashfs.LZ4_COMPRESSION: (NativeLZ4, PythonLZ4), + c_squashfs.LZ4_COMPRESSION: (AvailableLZ4,), c_squashfs.ZSTD_COMPRESSION: (NativeZSTD,), } @@ -60,14 +60,7 @@ def decompress(self, data: bytes, expected: int) -> bytes: return self._module.decompress(data) -class NativeLZO(Compression): - module = "lzo" - - def decompress(self, data: bytes, expected: int) -> bytes: - return self._module.decompress(data, False, expected) - - -class PythonLZO(Compression): +class AvailableLZO(Compression): module = "dissect.util.compression.lzo" def decompress(self, data: bytes, expected: int) -> bytes: @@ -81,18 +74,11 @@ def decompress(self, data: bytes, expected: int) -> bytes: return self._module.decompress(data) -class NativeLZ4(Compression): - module = "lz4.block" - - def decompress(self, data: bytes, expected: int) -> bytes: - return self._module.decompress(data, expected) - - -class PythonLZ4(Compression): +class AvailableLZ4(Compression): module = "dissect.util.compression.lz4" def decompress(self, data: bytes, expected: int) -> bytes: - return self._module.decompress(data) + return self._module.decompress(data, uncompressed_size=expected) class NativeZSTD(Compression): diff --git a/pyproject.toml b/pyproject.toml index dc0127f..288eae7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,10 +37,6 @@ repository = "https://github.com/fox-it/dissect.squashfs" [project.optional-dependencies] full = [ - "lz4", - # There are no Windows PyPy wheels available for python-lzo - # So we use a pure python fallback for it. - "python-lzo; platform_system != 'Windows' or platform_python_implementation != 'PyPy'", "zstandard", ] dev = [