Skip to content

Commit dcddaac

Browse files
authored
Merge pull request #22 from pycompression/release_0.2.0
Release 0.2.0
2 parents c177799 + 9e915fb commit dcddaac

File tree

8 files changed

+135
-53
lines changed

8 files changed

+135
-53
lines changed

.github/workflows/ci.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Continous integration
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- develop
8+
- master
9+
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-20.04
14+
strategy:
15+
matrix:
16+
python-version:
17+
- 3.6
18+
steps:
19+
- uses: actions/[email protected]
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v2
22+
- name: Install tox
23+
run: pip install tox
24+
- name: Lint
25+
run: tox -e lint
26+
docs:
27+
needs: lint
28+
runs-on: ubuntu-20.04
29+
steps:
30+
- uses: actions/[email protected]
31+
- name: Set up Python ${{ matrix.python-version }}
32+
uses: actions/setup-python@v2
33+
- name: Install tox
34+
run: pip install tox
35+
- name: Install isal
36+
run: sudo apt-get install libisal-dev
37+
- name: Build docs
38+
run: tox -e docs
39+
test:
40+
runs-on: ubuntu-20.04
41+
strategy:
42+
matrix:
43+
python-version:
44+
- 3.6
45+
- 3.7
46+
- 3.8
47+
- 3.9
48+
needs: lint
49+
steps:
50+
- uses: actions/[email protected]
51+
- name: Set up Python ${{ matrix.python-version }}
52+
uses: actions/setup-python@v2
53+
- name: Install tox
54+
run: pip install tox
55+
- name: Install isal
56+
run: sudo apt-get install libisal-dev
57+
- name: Run tests
58+
run: tox -e py3
59+
- name: Upload coverage report
60+
if: ${{ matrix.python-version == 3.6 }} # Only upload coverage once
61+
uses: codecov/codecov-action@v1

.travis.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

CHANGELOG.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ 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 0.2.0
11+
-----------------
12+
+ Fixed a bug where writing of the gzip header would crash if an older version
13+
of Python 3.7 was used such as on Debian or Ubuntu. This is due to
14+
differences between point releases because of a backported feature. The code
15+
now checks if the backported feature is present.
16+
+ Added Python 3.9 to the testing.
17+
+ Fixed ``setup.py`` to list setuptools as a requirement.
18+
+ Changed homepage to reflect move to pycompression organization.
19+
1020
version 0.1.0
1121
-----------------
1222
+ Publish API documentation on readthedocs.

README.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
.. image:: https://img.shields.io/pypi/v/isal.svg
2+
:target: https://pypi.org/project/isal/
3+
:alt:
4+
5+
.. image:: https://img.shields.io/conda/v/conda-forge/python-isal.svg
6+
:target: https://github.com/conda-forge/python-isal-feedstock
7+
:alt:
8+
9+
.. image:: https://img.shields.io/pypi/pyversions/isal.svg
10+
:target: https://pypi.org/project/isal/
11+
:alt:
12+
13+
.. image:: https://img.shields.io/pypi/l/isal.svg
14+
:target: https://github.com/LUMC/isal/blob/main/LICENSE
15+
:alt:
16+
17+
.. image:: https://travis-ci.com/pycompression/python-isal.svg?branch=develop
18+
:target: https://travis-ci.com/github/pycompression/python-isal
19+
:alt:
20+
21+
.. image:: https://codecov.io/gh/pycompression/python-isal/branch/develop/graph/badge.svg
22+
:target: https://codecov.io/gh/pycompression/python-isal
23+
:alt:
24+
125
.. image:: https://readthedocs.org/projects/python-isal/badge
226
:target: https://python-isal.readthedocs.io
327
:alt:
@@ -30,6 +54,14 @@ conda-forge channel. Checkout the `ports documentation
3054
<https://github.com/intel/isa-l/wiki/Ports--Repos>`_ on the isa-l project wiki
3155
to find out how to install it.
3256

57+
python-isal can be installed via pypi with:
58+
59+
.. code-block::
60+
61+
pip install isal
62+
63+
This requires the isa-l library to be installed on your pc.
64+
3365
The latest development version of python-isal can be installed with
3466

3567
.. code-block::

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
setup(
3838
name="isal",
39-
version="0.1.0",
39+
version="0.2.0",
4040
description="Faster zlib and gzip compatible compression and "
4141
"decompression by providing python bindings for the isa-l "
4242
"library.",
@@ -50,21 +50,22 @@
5050
packages=find_packages('src'),
5151
package_dir={'': 'src'},
5252
package_data={'isal': ['*.pxd', '*.pyx']},
53-
url="https://github.com/rhpvorderman/python-isal",
53+
url="https://github.com/pycompression/python-isal",
5454
classifiers=[
5555
"Programming Language :: Python :: 3 :: Only",
5656
"Programming Language :: Python :: 3",
5757
"Programming Language :: Python :: 3.6",
5858
"Programming Language :: Python :: 3.7",
5959
"Programming Language :: Python :: 3.8",
60+
"Programming Language :: Python :: 3.9",
6061
"Programming Language :: Cython",
6162
"Development Status :: 3 - Alpha",
6263
"Topic :: System :: Archiving :: Compression",
6364
"License :: OSI Approved :: MIT License",
6465
],
6566
python_requires=">=3.6",
6667
setup_requires=["cython"],
67-
install_requires=[],
68+
install_requires=["setuptools"],
6869
ext_modules=[
6970
Extension("isal.isal_zlib", ["src/isal/isal_zlib.pyx"],
7071
libraries=["isal"], **EXTENSION_OPTS),

src/isal/igzip.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,27 @@ def flush(self, zlib_mode=isal_zlib.Z_SYNC_FLUSH):
159159
super().flush(zlib_mode)
160160

161161
def _write_gzip_header(self, compresslevel=_COMPRESS_LEVEL_TRADEOFF):
162-
# Determine what xfl flag is written for the compression level.
163-
# Equate the fast level to gzip level 1. All the other levels are
164-
# medium.
165-
if sys.version_info[0] == 3 and sys.version_info[1] < 7:
166-
# Correct header introduced in 3.7
167-
super()._write_gzip_header()
168-
else:
162+
# Python 3.9 added a `compresslevel` parameter to write gzip header.
163+
# This only determines the value of one extra flag. Because this change
164+
# was backported to 3.7 and 3.8 in later point versions, the attributes
165+
# of the function should be checked before trying to use the
166+
# compresslevel parameter.
167+
# The gzip header has an extra flag that can be set depending on the
168+
# compression level used. This should be set when either the fastest or
169+
# best method is used. ISAL level 0 is larger than gzip level 1 and
170+
# much faster, so setting the flag for fastest level is appropriate.
171+
# ISAL level 1,2 and 3 (best)are similar in size and fall around the
172+
# gzip level 3 size. So setting no extra flag
173+
# (by using COMPRESS_LEVEL_TRADEOFF) is appropriate here.
174+
if ("compresslevel" in super()._write_gzip_header.__code__.co_varnames
175+
and hasattr(gzip, "_COMPRESS_LEVEL_FAST")
176+
and hasattr(gzip, "_COMPRESS_LEVEL_TRADEOFF")):
169177
if compresslevel == _COMPRESS_LEVEL_FAST:
170-
compresslevel = gzip._COMPRESS_LEVEL_FAST
178+
super()._write_gzip_header(gzip._COMPRESS_LEVEL_FAST)
171179
else:
172-
compresslevel = gzip._COMPRESS_LEVEL_TRADEOFF
173-
super()._write_gzip_header(compresslevel)
180+
super()._write_gzip_header(gzip._COMPRESS_LEVEL_TRADEOFF)
181+
else:
182+
super()._write_gzip_header()
174183

175184
def write(self, data):
176185
self._check_not_closed()

tests/test_gzip_compliance.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,11 @@ def test_metadata(self):
365365
struct.pack('<i', mtime)) # little-endian
366366

367367
xflByte = fRead.read(1)
368-
if sys.version_info[0] == 3 and sys.version_info[1] < 7:
369-
self.assertEqual(xflByte, b'\x02') # maximum compression
368+
if ("compresslevel" in
369+
gzip.GzipFile._write_gzip_header.__code__.co_varnames):
370+
self.assertEqual(xflByte, b'\x00') # fast compression
370371
else:
371-
self.assertEqual(xflByte, b'\x00') # medium compression
372+
self.assertEqual(xflByte, b'\x02') # maximum compression
372373
osByte = fRead.read(1)
373374
self.assertEqual(osByte, b'\xff') # OS "unknown" (OS-independent)
374375

@@ -399,8 +400,9 @@ def test_compresslevel_metadata(self):
399400
# specifically, discussion of XFL in section 2.3.1
400401
cases = [
401402
('fast', 0, b'\x04'),
402-
('best', 3, b'\x00'), # Comparable to medium gzip level.
403-
('tradeoff', 2, b'\x00'), # Dito
403+
('best', 3, b'\x00'), # Smaller than fast, bigger than best gzip.
404+
('tradeoff', 2, b'\x00'), # therefore medium is appropriate.
405+
('1', 1, b'\x00')
404406
]
405407
xflOffset = 8
406408

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ commands=
2525
deps=flake8
2626
flake8-import-order
2727
mypy
28+
# Linting does not need the installed package.
29+
skip_install=true
2830
commands =
2931
flake8 src tests setup.py benchmark.py
3032

0 commit comments

Comments
 (0)