Skip to content

Commit ffe04cb

Browse files
authored
Merge pull request #190 from pycompression/release_1.6.0
Release 1.6.0
2 parents f380197 + 015c719 commit ffe04cb

File tree

13 files changed

+49
-40
lines changed

13 files changed

+49
-40
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
- "3.10"
6363
- "3.11"
6464
- "3.12"
65+
- "3.13-dev"
6566
- "pypy-3.9"
6667
- "pypy-3.10"
6768
os: ["ubuntu-latest"]

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "src/isal/isa-l"]
22
path = src/isal/isa-l
3-
url = https://github.com/rhpvorderman/isa-l.git
3+
url = https://github.com/intel/isa-l.git

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ Changelog
77
.. This document is user facing. Please word the changes in such a way
88
.. that users understand how the changes affect the new version.
99
10+
version 1.6.0
11+
-----------------
12+
+ Fix a bug where compression levels for IGzipFile where checked in read mode.
13+
+ Update statically linked ISA-L release to 2.31.0
14+
+ Fix an error that occurred in the ``__close__`` function when a threaded
15+
writer was initialized with incorrect parameters.
16+
1017
version 1.5.3
1118
-----------------
1219
+ Fix a bug where append mode would not work when using

setup.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,11 @@
3333
DEFAULT_CACHE_FILE))
3434

3535
EXTENSIONS = [
36-
Extension("isal.isal_zlib", ["src/isal/isal_zlibmodule.c"]),
37-
Extension("isal.igzip_lib", ["src/isal/igzip_libmodule.c"]),
36+
Extension("isal.isal_zlib", ["src/isal/isal_zlibmodule.c"]),
37+
Extension("isal.igzip_lib", ["src/isal/igzip_libmodule.c"]),
38+
Extension("isal._isal", ["src/isal/_isalmodule.c"]),
3839
]
3940

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

4742
class BuildIsalExt(build_ext):
4843
def build_extension(self, ext):
@@ -135,7 +130,7 @@ def build_isa_l():
135130

136131
setup(
137132
name="isal",
138-
version="1.5.3",
133+
version="1.6.0",
139134
description="Faster zlib and gzip compatible compression and "
140135
"decompression by providing python bindings for the ISA-L "
141136
"library.",

src/isal/__init__.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,8 @@
55
# This file is part of python-isal which is distributed under the
66
# PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2.
77

8-
from typing import Optional
9-
10-
try:
11-
from . import _isal
12-
ISAL_MAJOR_VERSION: Optional[int] = _isal.ISAL_MAJOR_VERSION
13-
ISAL_MINOR_VERSION: Optional[int] = _isal.ISAL_MINOR_VERSION
14-
ISAL_PATCH_VERSION: Optional[int] = _isal.ISAL_PATCH_VERSION
15-
ISAL_VERSION: Optional[str] = _isal.ISAL_VERSION
16-
except ImportError:
17-
ISAL_MAJOR_VERSION = None
18-
ISAL_MINOR_VERSION = None
19-
ISAL_PATCH_VERSION = None
20-
ISAL_VERSION = None
8+
from ._isal import (ISAL_MAJOR_VERSION, ISAL_MINOR_VERSION, ISAL_PATCH_VERSION,
9+
ISAL_VERSION)
2110

2211
__all__ = [
2312
"ISAL_MAJOR_VERSION",
@@ -27,4 +16,4 @@
2716
"__version__"
2817
]
2918

30-
__version__ = "1.5.3"
19+
__version__ = "1.6.0"

src/isal/igzip.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,12 @@ def __init__(self, filename=None, mode=None,
151151
If omitted or None, the current time is used.
152152
"""
153153
if not (isal_zlib.ISAL_BEST_SPEED <= compresslevel
154-
<= isal_zlib.ISAL_BEST_COMPRESSION):
154+
<= isal_zlib.ISAL_BEST_COMPRESSION) and "r" not in mode:
155155
raise ValueError(
156-
"Compression level should be between {0} and {1}.".format(
157-
isal_zlib.ISAL_BEST_SPEED, isal_zlib.ISAL_BEST_COMPRESSION
158-
))
156+
f"Compression level should be between "
157+
f"{isal_zlib.ISAL_BEST_SPEED} and "
158+
f"{isal_zlib.ISAL_BEST_COMPRESSION}, got {compresslevel}."
159+
)
159160
super().__init__(filename, mode, compresslevel, fileobj, mtime)
160161
if self.mode == WRITE:
161162
self.compress = isal_zlib.compressobj(compresslevel,

src/isal/igzip_threaded.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ def __init__(self,
204204
queue_size: int = 1,
205205
block_size: int = 1024 * 1024,
206206
):
207+
# File should be closed during init, so __exit__ method does not
208+
# touch the self.raw value before it is initialized.
209+
self._closed = True
207210
if "t" in mode or "r" in mode:
208211
raise ValueError("Only binary writing is supported")
209212
if "b" not in mode:
@@ -243,8 +246,8 @@ def __init__(self,
243246
self._crc = 0
244247
self.running = False
245248
self._size = 0
246-
self._closed = False
247249
self.raw = open_as_binary_stream(filename, mode)
250+
self._closed = False
248251
self._write_gzip_header()
249252
self.start()
250253

src/isal/isa-l

Submodule isa-l updated 314 files

src/isal/isal_zlibmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,7 @@ GzipReader_readall(GzipReader *self, PyObject *Py_UNUSED(ignore))
20172017
Py_DECREF(chunk_list);
20182018
return NULL;
20192019
}
2020-
PyObject *ret = _PyBytes_Join(empty_bytes, chunk_list);
2020+
PyObject *ret = PyObject_CallMethod(empty_bytes, "join", "O", chunk_list);
20212021
Py_DECREF(empty_bytes);
20222022
Py_DECREF(chunk_list);
20232023
return ret;

tests/test_compat.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import gzip
1313
import itertools
14-
import os
1514
import zlib
1615
from pathlib import Path
1716

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

38-
DYNAMICALLY_LINKED = os.getenv("PYTHON_ISAL_LINK_DYNAMIC") is not None
39-
4037

4138
@pytest.mark.parametrize(["data_size", "value"],
4239
itertools.product(DATA_SIZES, SEEDS))
@@ -93,8 +90,6 @@ def test_decompress_isal_zlib(data_size, level):
9390
@pytest.mark.parametrize(["data_size", "level", "wbits", "memLevel"],
9491
itertools.product([128 * 1024], range(4),
9592
WBITS_RANGE, range(1, 10)))
96-
@pytest.mark.xfail(condition=DYNAMICALLY_LINKED,
97-
reason="Dynamically linked version may not have patch.")
9893
def test_compress_compressobj(data_size, level, wbits, memLevel):
9994
data = DATA[:data_size]
10095
compressobj = isal_zlib.compressobj(level=level,

tests/test_gzip_compliance.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,13 @@ def test_with_open(self):
456456
else:
457457
self.fail("1/0 didn't raise an exception")
458458

459+
def test_read_and_compresslevel(self):
460+
with igzip.GzipFile(self.filename, "wb") as f:
461+
f.write(b"xxx")
462+
with igzip.GzipFile(self.filename, "rb", compresslevel=17) as f:
463+
data = f.read()
464+
assert data == b"xxx"
465+
459466
def test_zero_padded_file(self):
460467
with igzip.GzipFile(self.filename, "wb") as f:
461468
f.write(data1 * 50)
@@ -785,6 +792,13 @@ def test_newline(self):
785792
with igzip.open(self.filename, "rt", newline="\r") as f:
786793
self.assertEqual(f.readlines(), [uncompressed])
787794

795+
def test_reading_and_compresslevel(self):
796+
with igzip.open(self.filename, "wb") as f:
797+
f.write(data1)
798+
with igzip.open(self.filename, "rb", compresslevel=17) as f:
799+
text = f.read()
800+
assert text == data1
801+
788802

789803
def create_and_remove_directory(directory):
790804
def decorator(function):

tests/test_igzip_threaded.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,11 @@ def test_igzip_threaded_append_text_mode(tmp_path):
191191
with gzip.open(test_file, "rt") as f:
192192
contents = f.read()
193193
assert contents == "ABCD"
194+
195+
196+
def test_igzip_threaded_open_compresslevel_and_reading(tmp_path):
197+
test_file = tmp_path / "test.txt.gz"
198+
test_file.write_bytes(gzip.compress(b"thisisatest"))
199+
with igzip_threaded.open(test_file, compresslevel=5) as f:
200+
text = f.read()
201+
assert text == b"thisisatest"

tests/test_zlib_compliance.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@
4040

4141

4242
class VersionTestCase(unittest.TestCase):
43-
44-
@unittest.skipIf(os.getenv("PYTHON_ISAL_LINK_DYNAMIC") is not None and
45-
sys.platform.startswith("win"),
46-
"Header file missing on windows")
4743
def test_library_version(self):
4844
# Test that the major version of the actual library in use matches the
4945
# major version that we were compiled against. We can't guarantee that

0 commit comments

Comments
 (0)