Skip to content

Commit c8e645b

Browse files
authored
Merge pull request #105 from pycompression/cmodulefromscratch
Rewrite extension module in C.
2 parents dfd24d5 + 32857e5 commit c8e645b

30 files changed

+3555
-2229
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
- uses: actions/[email protected]
2020
with:
2121
submodules: recursive
22-
- name: Set up Python 3.6
22+
- name: Set up Python 3.7
2323
uses: actions/[email protected]
2424
with:
25-
python-version: 3.6
25+
python-version: 3.7
2626
- name: Install tox
2727
run: pip install tox
2828
- name: Lint
@@ -40,10 +40,10 @@ jobs:
4040
- uses: actions/[email protected]
4141
with:
4242
submodules: recursive
43-
- name: Set up Python 3.6
43+
- name: Set up Python 3.7
4444
uses: actions/[email protected]
4545
with:
46-
python-version: 3.6
46+
python-version: 3.7
4747
- name: Install isal
4848
run: sudo apt-get install libisal-dev
4949
- name: Install tox and upgrade setuptools and pip
@@ -59,19 +59,16 @@ jobs:
5959
strategy:
6060
matrix:
6161
python-version:
62-
- "3.6"
6362
- "3.7"
6463
- "3.8"
6564
- "3.9"
6665
- "3.10"
67-
- "pypy-3.6"
68-
- "pypy-3.7"
6966
os: ["ubuntu-latest"]
7067
include:
7168
- os: "macos-latest"
72-
python-version: 3.6
69+
python-version: 3.7
7370
- os: "windows-latest"
74-
python-version: 3.6
71+
python-version: 3.7
7572
steps:
7673
- uses: actions/[email protected]
7774
with:
@@ -138,10 +135,6 @@ jobs:
138135
# strategy:
139136
# matrix:
140137
# os: ["ubuntu-latest", "macos-latest", "windows-latest"]
141-
# python_version: ["python"]
142-
# include:
143-
# - os: "ubuntu-latest"
144-
# python_version: "pypy"
145138
# steps:
146139
# - uses: actions/[email protected]
147140
# with:
@@ -151,7 +144,7 @@ jobs:
151144
# with:
152145
# channels: conda-forge,defaults
153146
# - name: Install requirements (universal)
154-
# run: conda install isa-l ${{ matrix.python_version}} tox
147+
# run: conda install isa-l python tox
155148
# - name: Set MSVC developer prompt
156149
# uses: ilammy/[email protected]
157150
# if: runner.os == 'Windows'
@@ -215,7 +208,7 @@ jobs:
215208
- name: Build wheels
216209
run: cibuildwheel --output-dir dist
217210
env:
218-
CIBW_SKIP: "*-win32 *-manylinux_i686" # Skip 32 bit.
211+
CIBW_SKIP: "*-win32 *-manylinux_i686 *pp3*" # Skip 32 bit and pypy
219212
CIBW_ARCHS_LINUX: ${{ matrix.cibw_archs_linux }}
220213
CIBW_BEFORE_ALL_LINUX: ${{ matrix.cibw_before_all_linux }}
221214
# Fully test the build wheels again.

CHANGELOG.rst

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,30 @@ Changelog
99
1010
version 1.0.0-dev
1111
------------------
12+
Python-isal has been rewritten as a C-extension (first implementation was in
13+
Cython). This has made the library faster in many key areas. It does mean
14+
that PyPy is no longer supported.
15+
16+
+ Since the module now mostly contains code copied from CPython and then
17+
modified to work with ISA-L the license has been changed to the
18+
Python Software Foundation License version 2.
19+
+ Python versions lower than 3.7 are no longer supported. Python 3.6 is out
20+
of support since December 2021.
21+
+ PyPy is no longer supported. PyPy+python-isal was slower than CPython + zlib
22+
for decompressing gzip files. PyPy should not be used for workloads that
23+
require heavy zlib-compatible compression/decompression. As such it was
24+
deemed unnecessary to continue supporting PyPy.
25+
+ Cython is no longer required as a build dependency.
26+
+ a fast function calling method ``METH_FASTCALL`` is now used to call the
27+
functions. This method is only supported by Python 3.7 and higher. This has
28+
reduced the overhead for all function calls from python-isal.
29+
+ isal_zlib.compressobj and isal_zlib.decompressobj are now about six times
30+
faster.
31+
+ igzip.decompress has 30% less overhead when called.
32+
+ ``isal_zlib`` functions now raise ``isal_zlib.error`` on error.
33+
``isal_zlib.IsalError`` has been removed.
34+
+ The base class for ``isal_zlib.error`` and ``igzip_lib.IsalError`` is now
35+
``Exception`` instead of ``OSError``.
1236
+ ISA-L library version variables are now available on windows as well.
1337
+ Wheels are now always build with nasm for the x86 architecture. Previously
1438
yasm was used for Linux and MacOS due to build issues that have since been
@@ -21,8 +45,6 @@ version 1.0.0-dev
2145
+ Support and tests for Python 3.10 were added.
2246
+ Due to a change in the deployment process wheels should work for older
2347
versions of pip.
24-
+ Added a ``igzip_lib.decompressobj`` function to initiate an IgzipDecompressor
25-
class.
2648
+ Added a ``crc`` property to the IgzipDecompressor class. Depending on the
2749
decompression flag chosen, this will update with an adler32 or crc32
2850
checksum.

LICENSE

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,48 @@
1-
MIT License
2-
3-
Copyright (c) 2020 Leiden University Medical Center
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
1+
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
2+
--------------------------------------------
3+
4+
1. This LICENSE AGREEMENT is between the Python Software Foundation
5+
("PSF"), and the Individual or Organization ("Licensee") accessing and
6+
otherwise using this software ("Python") in source or binary form and
7+
its associated documentation.
8+
9+
2. Subject to the terms and conditions of this License Agreement, PSF hereby
10+
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
11+
analyze, test, perform and/or display publicly, prepare derivative works,
12+
distribute, and otherwise use Python alone or in any derivative version,
13+
provided, however, that PSF's License Agreement and PSF's notice of copyright,
14+
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
15+
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Python Software Foundation;
16+
All Rights Reserved" are retained in Python alone or in any derivative version
17+
prepared by Licensee.
18+
19+
3. In the event Licensee prepares a derivative work that is based on
20+
or incorporates Python or any part thereof, and wants to make
21+
the derivative work available to others as provided herein, then
22+
Licensee hereby agrees to include in any such work a brief summary of
23+
the changes made to Python.
24+
25+
4. PSF is making Python available to Licensee on an "AS IS"
26+
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
27+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
28+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
29+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
30+
INFRINGE ANY THIRD PARTY RIGHTS.
31+
32+
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
33+
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
34+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
35+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
36+
37+
6. This License Agreement will automatically terminate upon a material
38+
breach of its terms and conditions.
39+
40+
7. Nothing in this License Agreement shall be deemed to create any
41+
relationship of agency, partnership, or joint venture between PSF and
42+
Licensee. This License Agreement does not grant permission to use PSF
43+
trademarks or trade name in a trademark sense to endorse or promote
44+
products or services of Licensee, or any third party.
45+
46+
8. By copying, installing or otherwise using Python, Licensee
47+
agrees to be bound by the terms and conditions of this License
48+
Agreement.

docs/index.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ API Documentation: isal_zlib
9999
.. automodule:: isal.isal_zlib
100100
:members:
101101

102+
.. autoclass:: Compress
103+
:members:
104+
105+
.. autoclass:: Decompress
106+
:members:
107+
102108
========================
103109
API-documentation: igzip
104110
========================
@@ -115,7 +121,10 @@ API Documentation: igzip_lib
115121
============================
116122

117123
.. automodule:: isal.igzip_lib
118-
:members:
124+
:members: compress, decompress,
125+
126+
.. autoclass:: IgzipDecompressor
127+
:members:
119128

120129
==========================
121130
python -m isal.igzip usage

pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
[build-system]
2-
requires = ["setuptools>=51", "cython>=0.29", "wheel"]
2+
requires = ["setuptools>=51", "wheel"]
33
build-backend = "setuptools.build_meta"
4-
5-
# [tool.coverage.run]
6-
# plugins = ["Cython.Coverage"]

setup.py

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
# Copyright (c) 2020 Leiden University Medical Center
2-
#
3-
# Permission is hereby granted, free of charge, to any person obtaining a copy
4-
# of this software and associated documentation files (the "Software"), to deal
5-
# in the Software without restriction, including without limitation the rights
6-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7-
# copies of the Software, and to permit persons to whom the Software is
8-
# furnished to do so, subject to the following conditions:
9-
#
10-
# The above copyright notice and this permission notice shall be included in
11-
# all copies or substantial portions of the Software.
12-
#
13-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19-
# SOFTWARE.
2+
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
3+
# 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022
4+
# Python Software Foundation; All Rights Reserved
5+
6+
# This file is part of python-isal which is distributed under the
7+
# PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2.
8+
209
import copy
2110
import functools
2211
import os
@@ -26,8 +15,6 @@
2615
import tempfile
2716
from pathlib import Path
2817

29-
from Cython.Build import cythonize
30-
3118
from setuptools import Extension, find_packages, setup
3219
from setuptools.command.build_ext import build_ext
3320

@@ -46,21 +33,6 @@
4633
DEFAULT_CACHE_FILE))
4734

4835

49-
def cythonize_modules():
50-
extension_args = dict()
51-
compiler_directives = dict(binding=True, language_level="3", profile=True)
52-
if os.getenv("CYTHON_COVERAGE") is not None:
53-
compiler_directives['linetrace'] = True
54-
extension_args["define_macros"] = [("CYTHON_TRACE_NOGIL", "1")]
55-
modules = [Extension("isal.isal_zlib", ["src/isal/isal_zlib.pyx"],
56-
**extension_args),
57-
Extension("isal.igzip_lib", ["src/isal/igzip_lib.pyx"],
58-
**extension_args),
59-
Extension("isal._isal", ["src/isal/_isal.pyx"],
60-
**extension_args)]
61-
return cythonize(modules, compiler_directives=compiler_directives)
62-
63-
6436
class BuildIsalExt(build_ext):
6537
def build_extension(self, ext):
6638
# Add option to link dynamically for packaging systems such as conda.
@@ -187,12 +159,12 @@ def build_isa_l(compiler_command: str, compiler_options: str):
187159
long_description=Path("README.rst").read_text(),
188160
long_description_content_type="text/x-rst",
189161
cmdclass={"build_ext": BuildIsalExt},
190-
license="MIT",
162+
license="PSF-2.0",
191163
keywords="isal isa-l compression deflate gzip igzip",
192164
zip_safe=False,
193165
packages=find_packages('src'),
194166
package_dir={'': 'src'},
195-
package_data={'isal': ['*.pxd', '*.pyx', '*.pyi', 'py.typed',
167+
package_data={'isal': ['*.pyi', 'py.typed', '*.c', '*.h',
196168
# Include isa-l LICENSE and other relevant files
197169
# with the binary distribution.
198170
'isa-l/LICENSE', 'isa-l/README.md',
@@ -201,19 +173,22 @@ def build_isa_l(compiler_command: str, compiler_options: str):
201173
classifiers=[
202174
"Programming Language :: Python :: 3 :: Only",
203175
"Programming Language :: Python :: 3",
204-
"Programming Language :: Python :: 3.6",
205176
"Programming Language :: Python :: 3.7",
206177
"Programming Language :: Python :: 3.8",
207178
"Programming Language :: Python :: 3.9",
208179
"Programming Language :: Python :: 3.10",
209180
"Programming Language :: Cython",
210181
"Development Status :: 5 - Production/Stable",
211182
"Topic :: System :: Archiving :: Compression",
212-
"License :: OSI Approved :: MIT License",
183+
"License :: OSI Approved :: Python Software Foundation License",
213184
"Operating System :: POSIX :: Linux",
214185
"Operating System :: MacOS",
215186
"Operating System :: Microsoft :: Windows",
216187
],
217-
python_requires=">=3.6",
218-
ext_modules=cythonize_modules()
188+
python_requires=">=3.7", # We use METH_FASTCALL
189+
ext_modules=[
190+
Extension("isal.isal_zlib", ["src/isal/isal_zlib.c"]),
191+
Extension("isal.igzip_lib", ["src/isal/igzip_lib.c"]),
192+
Extension("isal._isal", ["src/isal/_isal.c"])
193+
]
219194
)

src/isal/__init__.pxd

Whitespace-only changes.

src/isal/__init__.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
1-
# Copyright (c) 2020 Leiden University Medical Center
2-
#
3-
# Permission is hereby granted, free of charge, to any person obtaining a copy
4-
# of this software and associated documentation files (the "Software"), to deal
5-
# in the Software without restriction, including without limitation the rights
6-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7-
# copies of the Software, and to permit persons to whom the Software is
8-
# furnished to do so, subject to the following conditions:
9-
#
10-
# The above copyright notice and this permission notice shall be included in
11-
# all copies or substantial portions of the Software.
12-
#
13-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19-
# SOFTWARE.
1+
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2+
# 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022
3+
# Python Software Foundation; All Rights Reserved
4+
5+
# This file is part of python-isal which is distributed under the
6+
# PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2.
207

218
from . import _isal
229

0 commit comments

Comments
 (0)