Skip to content

Commit

Permalink
Merge pull request #190 from pycompression/release_1.6.0
Browse files Browse the repository at this point in the history
Release 1.6.0
  • Loading branch information
rhpvorderman authored Feb 19, 2024
2 parents f380197 + 015c719 commit ffe04cb
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 40 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
- "3.10"
- "3.11"
- "3.12"
- "3.13-dev"
- "pypy-3.9"
- "pypy-3.10"
os: ["ubuntu-latest"]
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "src/isal/isa-l"]
path = src/isal/isa-l
url = https://github.com/rhpvorderman/isa-l.git
url = https://github.com/intel/isa-l.git
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ Changelog
.. This document is user facing. Please word the changes in such a way
.. that users understand how the changes affect the new version.
version 1.6.0
-----------------
+ Fix a bug where compression levels for IGzipFile where checked in read mode.
+ Update statically linked ISA-L release to 2.31.0
+ Fix an error that occurred in the ``__close__`` function when a threaded
writer was initialized with incorrect parameters.

version 1.5.3
-----------------
+ Fix a bug where append mode would not work when using
Expand Down
13 changes: 4 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,11 @@
DEFAULT_CACHE_FILE))

EXTENSIONS = [
Extension("isal.isal_zlib", ["src/isal/isal_zlibmodule.c"]),
Extension("isal.igzip_lib", ["src/isal/igzip_libmodule.c"]),
Extension("isal.isal_zlib", ["src/isal/isal_zlibmodule.c"]),
Extension("isal.igzip_lib", ["src/isal/igzip_libmodule.c"]),
Extension("isal._isal", ["src/isal/_isalmodule.c"]),
]

# This does not add the extension on windows for dynamic linking. The required
# header file might be missing.
if not (SYSTEM_IS_WINDOWS and
os.getenv("PYTHON_ISAL_LINK_DYNAMIC") is not None):
EXTENSIONS.append(Extension("isal._isal", ["src/isal/_isalmodule.c"]))


class BuildIsalExt(build_ext):
def build_extension(self, ext):
Expand Down Expand Up @@ -135,7 +130,7 @@ def build_isa_l():

setup(
name="isal",
version="1.5.3",
version="1.6.0",
description="Faster zlib and gzip compatible compression and "
"decompression by providing python bindings for the ISA-L "
"library.",
Expand Down
17 changes: 3 additions & 14 deletions src/isal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,8 @@
# This file is part of python-isal which is distributed under the
# PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2.

from typing import Optional

try:
from . import _isal
ISAL_MAJOR_VERSION: Optional[int] = _isal.ISAL_MAJOR_VERSION
ISAL_MINOR_VERSION: Optional[int] = _isal.ISAL_MINOR_VERSION
ISAL_PATCH_VERSION: Optional[int] = _isal.ISAL_PATCH_VERSION
ISAL_VERSION: Optional[str] = _isal.ISAL_VERSION
except ImportError:
ISAL_MAJOR_VERSION = None
ISAL_MINOR_VERSION = None
ISAL_PATCH_VERSION = None
ISAL_VERSION = None
from ._isal import (ISAL_MAJOR_VERSION, ISAL_MINOR_VERSION, ISAL_PATCH_VERSION,
ISAL_VERSION)

__all__ = [
"ISAL_MAJOR_VERSION",
Expand All @@ -27,4 +16,4 @@
"__version__"
]

__version__ = "1.5.3"
__version__ = "1.6.0"
9 changes: 5 additions & 4 deletions src/isal/igzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,12 @@ def __init__(self, filename=None, mode=None,
If omitted or None, the current time is used.
"""
if not (isal_zlib.ISAL_BEST_SPEED <= compresslevel
<= isal_zlib.ISAL_BEST_COMPRESSION):
<= isal_zlib.ISAL_BEST_COMPRESSION) and "r" not in mode:
raise ValueError(
"Compression level should be between {0} and {1}.".format(
isal_zlib.ISAL_BEST_SPEED, isal_zlib.ISAL_BEST_COMPRESSION
))
f"Compression level should be between "
f"{isal_zlib.ISAL_BEST_SPEED} and "
f"{isal_zlib.ISAL_BEST_COMPRESSION}, got {compresslevel}."
)
super().__init__(filename, mode, compresslevel, fileobj, mtime)
if self.mode == WRITE:
self.compress = isal_zlib.compressobj(compresslevel,
Expand Down
5 changes: 4 additions & 1 deletion src/isal/igzip_threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ def __init__(self,
queue_size: int = 1,
block_size: int = 1024 * 1024,
):
# File should be closed during init, so __exit__ method does not
# touch the self.raw value before it is initialized.
self._closed = True
if "t" in mode or "r" in mode:
raise ValueError("Only binary writing is supported")
if "b" not in mode:
Expand Down Expand Up @@ -243,8 +246,8 @@ def __init__(self,
self._crc = 0
self.running = False
self._size = 0
self._closed = False
self.raw = open_as_binary_stream(filename, mode)
self._closed = False
self._write_gzip_header()
self.start()

Expand Down
2 changes: 1 addition & 1 deletion src/isal/isa-l
Submodule isa-l updated 314 files
2 changes: 1 addition & 1 deletion src/isal/isal_zlibmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,7 @@ GzipReader_readall(GzipReader *self, PyObject *Py_UNUSED(ignore))
Py_DECREF(chunk_list);
return NULL;
}
PyObject *ret = _PyBytes_Join(empty_bytes, chunk_list);
PyObject *ret = PyObject_CallMethod(empty_bytes, "join", "O", chunk_list);
Py_DECREF(empty_bytes);
Py_DECREF(chunk_list);
return ret;
Expand Down
5 changes: 0 additions & 5 deletions tests/test_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import gzip
import itertools
import os
import zlib
from pathlib import Path

Expand All @@ -35,8 +34,6 @@
# Wbits for ZLIB compression, GZIP compression, and RAW compressed streams
WBITS_RANGE = list(range(9, 16)) + list(range(25, 32)) + list(range(-15, -8))

DYNAMICALLY_LINKED = os.getenv("PYTHON_ISAL_LINK_DYNAMIC") is not None


@pytest.mark.parametrize(["data_size", "value"],
itertools.product(DATA_SIZES, SEEDS))
Expand Down Expand Up @@ -93,8 +90,6 @@ def test_decompress_isal_zlib(data_size, level):
@pytest.mark.parametrize(["data_size", "level", "wbits", "memLevel"],
itertools.product([128 * 1024], range(4),
WBITS_RANGE, range(1, 10)))
@pytest.mark.xfail(condition=DYNAMICALLY_LINKED,
reason="Dynamically linked version may not have patch.")
def test_compress_compressobj(data_size, level, wbits, memLevel):
data = DATA[:data_size]
compressobj = isal_zlib.compressobj(level=level,
Expand Down
14 changes: 14 additions & 0 deletions tests/test_gzip_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,13 @@ def test_with_open(self):
else:
self.fail("1/0 didn't raise an exception")

def test_read_and_compresslevel(self):
with igzip.GzipFile(self.filename, "wb") as f:
f.write(b"xxx")
with igzip.GzipFile(self.filename, "rb", compresslevel=17) as f:
data = f.read()
assert data == b"xxx"

def test_zero_padded_file(self):
with igzip.GzipFile(self.filename, "wb") as f:
f.write(data1 * 50)
Expand Down Expand Up @@ -785,6 +792,13 @@ def test_newline(self):
with igzip.open(self.filename, "rt", newline="\r") as f:
self.assertEqual(f.readlines(), [uncompressed])

def test_reading_and_compresslevel(self):
with igzip.open(self.filename, "wb") as f:
f.write(data1)
with igzip.open(self.filename, "rb", compresslevel=17) as f:
text = f.read()
assert text == data1


def create_and_remove_directory(directory):
def decorator(function):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_igzip_threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,11 @@ def test_igzip_threaded_append_text_mode(tmp_path):
with gzip.open(test_file, "rt") as f:
contents = f.read()
assert contents == "ABCD"


def test_igzip_threaded_open_compresslevel_and_reading(tmp_path):
test_file = tmp_path / "test.txt.gz"
test_file.write_bytes(gzip.compress(b"thisisatest"))
with igzip_threaded.open(test_file, compresslevel=5) as f:
text = f.read()
assert text == b"thisisatest"
4 changes: 0 additions & 4 deletions tests/test_zlib_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@


class VersionTestCase(unittest.TestCase):

@unittest.skipIf(os.getenv("PYTHON_ISAL_LINK_DYNAMIC") is not None and
sys.platform.startswith("win"),
"Header file missing on windows")
def test_library_version(self):
# Test that the major version of the actual library in use matches the
# major version that we were compiled against. We can't guarantee that
Expand Down

0 comments on commit ffe04cb

Please sign in to comment.