Skip to content

Commit 78dda64

Browse files
authored
Merge pull request #119 from pycompression/applyisalpatches
Use a patched version of isa-l 2.30
2 parents 1b53203 + a9e9f3e commit 78dda64

File tree

8 files changed

+70
-48
lines changed

8 files changed

+70
-48
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -120,33 +120,33 @@ jobs:
120120
121121
# Test if the python-isal conda package can be build. Which is linked
122122
# dynamically to the conda isa-l package.
123-
# test-dynamic:
124-
# runs-on: ${{ matrix.os }}
125-
# defaults:
126-
# run:
127-
# # This is needed for miniconda, see:
128-
# # https://github.com/marketplace/actions/setup-miniconda#important.
129-
# shell: bash -l {0}
130-
# strategy:
131-
# matrix:
132-
# os: ["ubuntu-latest", "macos-latest", "windows-latest"]
133-
# steps:
134-
# - uses: actions/[email protected]
135-
# with:
136-
# submodules: recursive
137-
# - name: Install miniconda.
138-
# uses: conda-incubator/[email protected] # https://github.com/conda-incubator/setup-miniconda.
139-
# with:
140-
# channels: conda-forge,defaults
141-
# - name: Install requirements (universal)
142-
# run: conda install isa-l python tox
143-
# - name: Set MSVC developer prompt
144-
# uses: ilammy/[email protected]
145-
# if: runner.os == 'Windows'
146-
# - name: Run tests (dynamic link)
147-
# run: tox
148-
# env:
149-
# PYTHON_ISAL_LINK_DYNAMIC: True
123+
test-dynamic:
124+
runs-on: ${{ matrix.os }}
125+
defaults:
126+
run:
127+
# This is needed for miniconda, see:
128+
# https://github.com/marketplace/actions/setup-miniconda#important.
129+
shell: bash -l {0}
130+
strategy:
131+
matrix:
132+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
133+
steps:
134+
- uses: actions/[email protected]
135+
with:
136+
submodules: recursive
137+
- name: Install miniconda.
138+
uses: conda-incubator/[email protected] # https://github.com/conda-incubator/setup-miniconda.
139+
with:
140+
channels: conda-forge,defaults
141+
- name: Install requirements (universal)
142+
run: conda install isa-l python tox
143+
- name: Set MSVC developer prompt
144+
uses: ilammy/[email protected]
145+
if: runner.os == 'Windows'
146+
- name: Run tests (dynamic link)
147+
run: tox
148+
env:
149+
PYTHON_ISAL_LINK_DYNAMIC: True
150150

151151
deploy:
152152
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')

.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/intel/isa-l.git
3+
url = https://github.com/rhpvorderman/isa-l.git

CHANGELOG.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ that PyPy is no longer supported.
3737
IgzipDecompressor.decompress has been updated to allocate ``maxsize`` buffers
3838
when these are of reasonable size, instead of growing the buffer to maxsize
3939
on every call. This has improved gzip decompression speeds by 7%.
40-
+ ISA-L library version variables are now available on windows as well.
41-
+ Wheels are now always build with nasm for the x86 architecture. Previously
42-
yasm was used for Linux and MacOS due to build issues that have since been
43-
fixed upstream.
44-
+ Updated statically included ISA-L to version 2.31.0. This fixes the bug
45-
mentioned below in python-isal as well.
46-
+ Fixed a bug upstream in ISA-L were zlib headers would be created with an
47-
incorrect wbits value.
40+
+ Patch statically linked included library (ISA-L 2.30.0) to fix the following:
41+
42+
+ ISA-L library version variables are now available on windows as well,
43+
for the statically linked version available on PyPI.
44+
+ Wheels are now always build with nasm for the x86 architecture.
45+
Previously yasm was used for Linux and MacOS due to build issues.
46+
+ Fixed a bug upstream in ISA-L were zlib headers would be created with an
47+
incorrect wbits value.
48+
4849
+ Python-isal shows up in Python profiler reports.
4950
+ Support and tests for Python 3.10 were added.
5051
+ Due to a change in the deployment process wheels should work for older

setup.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@
3232
BUILD_CACHE_FILE = Path(os.environ.get("PYTHON_ISAL_BUILD_CACHE_FILE",
3333
DEFAULT_CACHE_FILE))
3434

35+
EXTENSIONS = [
36+
Extension("isal.isal_zlib", ["src/isal/isal_zlibmodule.c"]),
37+
Extension("isal.igzip_lib", ["src/isal/igzip_libmodule.c"]),
38+
]
39+
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+
3546

3647
class BuildIsalExt(build_ext):
3748
def build_extension(self, ext):
@@ -186,9 +197,5 @@ def build_isa_l(compiler_command: str, compiler_options: str):
186197
"Operating System :: Microsoft :: Windows",
187198
],
188199
python_requires=">=3.7", # We use METH_FASTCALL
189-
ext_modules=[
190-
Extension("isal.isal_zlib", ["src/isal/isal_zlibmodule.c"]),
191-
Extension("isal.igzip_lib", ["src/isal/igzip_libmodule.c"]),
192-
Extension("isal._isal", ["src/isal/_isalmodule.c"])
193-
]
200+
ext_modules=EXTENSIONS
194201
)

src/isal/__init__.py

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

8-
from . import _isal
9-
10-
ISAL_MAJOR_VERSION: int = _isal.ISAL_MAJOR_VERSION
11-
ISAL_MINOR_VERSION: int = _isal.ISAL_MINOR_VERSION
12-
ISAL_PATCH_VERSION: int = _isal.ISAL_PATCH_VERSION
13-
ISAL_VERSION: str = _isal.ISAL_VERSION
8+
from typing import Optional
149

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
1521

1622
__all__ = [
1723
"ISAL_MAJOR_VERSION",

src/isal/isa-l

Submodule isa-l updated 62 files

tests/test_compat.py

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

1212
import gzip
1313
import itertools
14+
import os
1415
import zlib
1516
from pathlib import Path
1617

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

38+
DYNAMICALLY_LINKED = os.getenv("PYTHON_ISAL_LINK_DYNAMIC") is not None
39+
3740

3841
@pytest.mark.parametrize(["data_size", "value"],
3942
itertools.product(DATA_SIZES, SEEDS))
@@ -90,6 +93,8 @@ def test_decompress_isal_zlib(data_size, level):
9093
@pytest.mark.parametrize(["data_size", "level", "wbits", "memLevel"],
9194
itertools.product([128 * 1024], range(4),
9295
WBITS_RANGE, range(1, 10)))
96+
@pytest.mark.xfail(condition=DYNAMICALLY_LINKED,
97+
reason="Dynamically linked version may not have patch.")
9398
def test_compress_compressobj(data_size, level, wbits, memLevel):
9499
data = DATA[:data_size]
95100
compressobj = isal_zlib.compressobj(level=level,

tests/test_zlib_compliance.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141

4242
class VersionTestCase(unittest.TestCase):
4343

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

0 commit comments

Comments
 (0)