Skip to content

Commit e3bb928

Browse files
authored
Merge pull request #23 from pycompression/staticlinking
Add isa-l source to allow for static linking. Allow building binary distributions on PyPI.
2 parents 850abd6 + c8a6259 commit e3bb928

File tree

12 files changed

+223
-68
lines changed

12 files changed

+223
-68
lines changed

.github/release_checklist.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Release checklist
44
- [ ] Create a release branch.
55
- [ ] Set version to a stable number.
66
- [ ] Change current development version in `CHANGELOG.rst` to stable version.
7+
- [ ] Change the version in `__init__.py`
78
- [ ] Merge the release branch into `main`.
89
- [ ] Create a test pypi package from the main branch. ([Instructions.](
910
https://packaging.python.org/tutorials/packaging-projects/#generating-distribution-archives

.github/workflows/ci.yml

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ on:
1111
jobs:
1212
lint:
1313
runs-on: ubuntu-20.04
14-
strategy:
15-
matrix:
16-
python-version:
17-
- 3.6
1814
steps:
1915
- uses: actions/[email protected]
20-
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v2
16+
with:
17+
submodules: recursive
18+
- name: Set up Python 3.6
19+
uses: actions/[email protected]
20+
with:
21+
python-version: 3.6
2222
- name: Install tox
2323
run: pip install tox
2424
- name: Lint
@@ -28,14 +28,20 @@ jobs:
2828
runs-on: ubuntu-20.04
2929
steps:
3030
- 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
31+
with:
32+
submodules: recursive
33+
- name: Set up Python 3.6
34+
uses: actions/[email protected]
35+
with:
36+
python-version: 3.6
3537
- name: Install isal
3638
run: sudo apt-get install libisal-dev
39+
- name: Install tox and upgrade setuptools and pip
40+
run: pip install --upgrade tox setuptools pip
3741
- name: Build docs
3842
run: tox -e docs
43+
env:
44+
PYTHON_ISAL_LINK_DYNAMIC: True
3945
test:
4046
runs-on: ubuntu-20.04
4147
strategy:
@@ -45,17 +51,34 @@ jobs:
4551
- 3.7
4652
- 3.8
4753
- 3.9
54+
linking_method:
55+
- static
56+
- dynamic
4857
needs: lint
4958
steps:
5059
- uses: actions/[email protected]
60+
with:
61+
submodules: recursive
5162
- name: Set up Python ${{ matrix.python-version }}
52-
uses: actions/setup-python@v2
53-
- name: Install tox
54-
run: pip install tox
63+
uses: actions/[email protected]
64+
with:
65+
python-version: ${{ matrix.python-version }}
66+
- name: Install tox and upgrade setuptools and pip
67+
run: pip install --upgrade tox setuptools pip
5568
- name: Install isal
69+
if: ${{ matrix.linking_method == 'dynamic' }}
5670
run: sudo apt-get install libisal-dev
57-
- name: Run tests
71+
- name: Install nasm
72+
run: sudo apt install nasm
73+
if: ${{ matrix.linking_method == 'static' }}
74+
- name: Run tests (dynamic link)
75+
run: tox -e py3
76+
env:
77+
PYTHON_ISAL_LINK_DYNAMIC: True
78+
if: ${{ matrix.linking_method == 'dynamic' }}
79+
- name: Run tests (dynamic link)
5880
run: tox -e py3
81+
if: ${{ matrix.linking_method == 'static' }}
5982
- name: Upload coverage report
60-
if: ${{ matrix.python-version == 3.6 }} # Only upload coverage once
83+
if: ${{ matrix.python-version == 3.6 && matrix.linking_method == 'static'}} # Only upload coverage once
6184
uses: codecov/codecov-action@v1

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "src/isal/isa-l"]
2+
path = src/isal/isa-l
3+
url = https://github.com/intel/isa-l.git

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ 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.3.0-dev
11+
-----------------
12+
+ Set included ISA-L library at version 2.30.0.
13+
+ Python-isal now comes with a source distribution of ISA-L in its source
14+
distribution against which python-isal is linked statically upon installation
15+
by default. Dynamic linking against system libraries is now optional. Wheels
16+
with the statically linked ISA-L are now provided on PyPI.
17+
1018
version 0.2.0
1119
-----------------
1220
+ Fixed a bug where writing of the gzip header would crash if an older version

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
graft src/isal/isa-l

README.rst

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ python-isal
3131
===========
3232

3333
Faster zlib and gzip compatible compression and decompression
34-
by providing python bindings for the isa-l library.
34+
by providing Python bindings for the ISA-L library.
3535

36-
This package provides Python bindings for the `isa-l
36+
This package provides Python bindings for the `ISA-L
3737
<https://github.com/intel/isa-l>`_ library. The Intel Infrastructure Storage
38-
Acceleration Library (isa-l) implements several key algorithms in `assembly
38+
Acceleration Library (ISA-L) implements several key algorithms in `assembly
3939
language <https://en.wikipedia.org/wiki/Assembly_language>`_. This includes
4040
a variety of functions to provide zlib/gzip-compatible compression.
4141

@@ -45,54 +45,58 @@ and ``gzip`` modules from the stdlib (with some minor exceptions, see below).
4545

4646
Installation
4747
------------
48-
Recommended installation via conda
49-
..................................
50-
The recommended installation is an installation via Conda. For example using
51-
the `miniconda <https://docs.conda.io/en/latest/miniconda.html>`_ installer
52-
with a properly setup `conda-forge
53-
<https://conda-forge.org/docs/user/introduction.html#how-can-i-install-packages-from-conda-forge>`_
54-
channel. When used with bioinformatics tools setting up `bioconda
55-
<http://bioconda.github.io/user/install.html#install-conda>`_
56-
provides a clear set of installation instructions for conda.
48+
Installation with pip
49+
.....................
50+
Python-isal can be installed with::
5751

58-
python-isal is available on conda-forge and can be installed with
52+
pip install isal
5953

60-
.. code-block::
54+
This will include a staticallly linked version of isa-l. On Linux, wheels
55+
are provided. If a wheel is not provided for your system the installation will
56+
build ISA-L first in a temporary directory. Please check the `ISA-L homepage
57+
<https://github.com/intel/isa-l>`_ for the build requirements.
6158

62-
conda install python-isal
59+
The latest development version of python-isal can be installed with::
6360

64-
This will automatically install the isa-l library dependency as well, since
65-
it is available on conda-forge.
61+
pip install git+https://github.com/rhpvorderman/python-isal.git
6662

67-
Installation with pip
68-
.....................
69-
isa-l version 2.26.0 or higher is needed on your system. This includes bindings
70-
for the adler32 function.
63+
If you wish to link
64+
dynamically against a version of libisal installed on your system use::
7165

72-
isa-l is available in numerous Linux distro's as well as on conda via the
66+
PYTHON_ISAL_LINK_DYNAMIC=true pip install isal
67+
68+
ISA-L is available in numerous Linux distro's as well as on conda via the
7369
conda-forge channel. Checkout the `ports documentation
74-
<https://github.com/intel/isa-l/wiki/Ports--Repos>`_ on the isa-l project wiki
75-
to find out how to install it. It is important that the development headers
70+
<https://github.com/intel/isa-l/wiki/Ports--Repos>`_ on the ISA-L project wiki
71+
to find out how to install it. It is important that the development headers
7672
are also installed.
7773

78-
On debian and ubuntu the isa-l libraries (including the development headers)
79-
can be installed with:
74+
On Debian and Ubuntu the ISA-L libraries (including the development headers)
75+
can be installed with:
8076

8177
.. code-block::
8278
8379
sudo apt install libisal-dev
8480
85-
python-isal can be installed via pypi with:
81+
Installation via conda
82+
..................................
83+
Python-isal can be installed via conda, for example using
84+
the `miniconda <https://docs.conda.io/en/latest/miniconda.html>`_ installer
85+
with a properly setup `conda-forge
86+
<https://conda-forge.org/docs/user/introduction.html#how-can-i-install-packages-from-conda-forge>`_
87+
channel. When used with bioinformatics tools setting up `bioconda
88+
<http://bioconda.github.io/user/install.html#install-conda>`_
89+
provides a clear set of installation instructions for conda.
8690

87-
.. code-block::
91+
python-isal is available on conda-forge and can be installed with
8892

89-
pip install isal
93+
.. code-block::
9094
91-
The latest development version of python-isal can be installed with
95+
conda install python-isal
9296
93-
.. code-block::
97+
This will automatically install the isa-l library dependency as well, since
98+
it is available on conda-forge.
9499

95-
pip install git+https://github.com/rhpvorderman/python-isal.git
96100

97101
Usage
98102
-----
@@ -122,7 +126,7 @@ Differences with zlib and gzip modules
122126

123127
+ Compression level 0 in ``zlib`` and ``gzip`` means **no compression**, while
124128
in ``isal_zlib`` and ``igzip`` this is the **lowest compression level**.
125-
This is a design choice that was inherited from the isa-l library.
129+
This is a design choice that was inherited from the ISA-L library.
126130
+ Compression levels range from 0 to 3, not 1 to 9.
127131
+ ``isal_zlib.crc32`` and ``isal_zlib.adler32`` do not support negative
128132
numbers for the value parameter.

buildwheels.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
#
3+
# This script was copied from github.com/marcelm/dnaio. Many thanks to Marcel!
4+
# The only adaptation was moving the script to manylinux2014.
5+
#
6+
# Build manylinux wheels. Based on the example at
7+
# <https://github.com/pypa/python-manylinux-demo>
8+
#
9+
# It is best to run this in a fresh clone of the repository!
10+
#
11+
# Run this within the repository root:
12+
# ./buildwheels.sh
13+
#
14+
# The wheels will be put into the dist/ subdirectory.
15+
16+
set -xeuo pipefail
17+
18+
manylinux=quay.io/pypa/manylinux2014_x86_64
19+
20+
# For convenience, if this script is called from outside of a docker container,
21+
# it starts a container and runs itself inside of it.
22+
if ! grep -q docker /proc/1/cgroup && ! test -d /opt/python; then
23+
# We are not inside a container
24+
docker pull ${manylinux}
25+
exec docker run --rm -v $(pwd):/io ${manylinux} /io/$0
26+
fi
27+
28+
if ! test -d /io/dist; then
29+
mkdir /io/dist
30+
chown --reference=/io/setup.py /io/dist
31+
fi
32+
33+
# Strip binaries (copied from multibuild)
34+
STRIP_FLAGS=${STRIP_FLAGS:-"-Wl,-strip-all"}
35+
export CFLAGS="${CFLAGS:-$STRIP_FLAGS}"
36+
export CXXFLAGS="${CXXFLAGS:-$STRIP_FLAGS}"
37+
38+
for PYBIN in /opt/python/cp3[6789]-*/bin; do
39+
${PYBIN}/pip wheel --no-deps /io/ -w wheelhouse/
40+
done
41+
ls wheelhouse/
42+
43+
# Bundle external shared libraries into the wheels
44+
for whl in wheelhouse/*.whl; do
45+
auditwheel repair "$whl" --plat manylinux2014_x86_64 -w repaired/
46+
done
47+
48+
# Created files are owned by root, so fix permissions.
49+
chown -R --reference=/io/setup.py repaired/
50+
mv repaired/*.whl /io/dist/

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools>=51", "cython>=0.29", "wheel"]
3+
build-backend = "setuptools.build_meta"

0 commit comments

Comments
 (0)