Skip to content

Commit

Permalink
Merge pull request #231 from grahamgower/libdeflate
Browse files Browse the repository at this point in the history
Add libdeflate to the wheel build.
  • Loading branch information
brentp committed Dec 7, 2021
2 parents 15b7de4 + ea95ed4 commit b339e1b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ jobs:
run: |
python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_SKIP: "pp* *i686*"
CIBW_SKIP: "pp* *i686* *musllinux*"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BEFORE_BUILD_LINUX: "{project}/ci/linux-deps"
CIBW_TEST_COMMAND: "{project}/ci/test"
CIBW_ENVIRONMENT: "CYTHONIZE=1 LDFLAGS='-L/usr/lib64/openssl11' CPPFLAGS='-I/usr/include/openssl11' C_INCLUDE_PATH='/root/include' LIBRARY_PATH='/root/lib'"
CIBW_ENVIRONMENT: "CYTHONIZE=1 LIBDEFLATE=1 LDFLAGS='-L/usr/lib64/openssl11' CPPFLAGS='-I/usr/include/openssl11' C_INCLUDE_PATH='/root/include' LIBRARY_PATH='/root/lib'"
CIBW_REPAIR_WHEEL_COMMAND_LINUX: LD_LIBRARY_PATH='/root/lib' auditwheel repair -w {dest_dir} {wheel}

- name: Build wheels for Mac OS
if: matrix.os == 'macos-latest'
Expand All @@ -56,7 +57,11 @@ jobs:
CIBW_BEFORE_BUILD_MACOS: "{project}/ci/osx-deps"
CIBW_TEST_COMMAND: "{project}/ci/test"
CIBW_TEST_SKIP: "*-macosx_arm64"
CIBW_ENVIRONMENT: "CYTHONIZE=1"
CIBW_ENVIRONMENT: "CYTHONIZE=1 LIBDEFLATE=1 C_INCLUDE_PATH='/usr/local/include' LIBRARY_PATH='/usr/local/lib'"
# https://cibuildwheel.readthedocs.io/en/stable/faq/#macos-passing-dyld_library_path-to-delocate
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
DYLD_LIBRARY_PATH=/usr/local/lib delocate-listdeps {wheel} &&
DYLD_LIBRARY_PATH=/usr/local/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}
LDFLAGS: "-L/usr/local/opt/[email protected]/lib"
CPPFLAGS: "-I/usr/local/opt/[email protected]/include"
PKG_CONFIG_PATH: "/usr/local/opt/[email protected]/lib/pkgconfig"
Expand Down
7 changes: 7 additions & 0 deletions ci/linux-deps
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ make install
cd ..
rm -rf curl-7.73.0

curl -L -o libdeflate-v1.8.tar.gz https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.8.tar.gz
tar xzf libdeflate-v1.8.tar.gz
cd libdeflate-1.8
make
make install PREFIX=/root
cd ..

cd htslib
# configure fails with autoconf 2.71 (in /usr/local/bin), so use 2.69 (in /usr/bin)
/usr/bin/autoconf -V
Expand Down
7 changes: 7 additions & 0 deletions ci/osx-deps
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ brew install [email protected] && \
brew link --overwrite [email protected] && \
autoconf -V

curl -L -o libdeflate-v1.8.tar.gz https://github.com/ebiggers/libdeflate/archive/refs/tags/v1.8.tar.gz
tar xzf libdeflate-v1.8.tar.gz
cd libdeflate-1.8
make
make install
cd ..

cd htslib
autoheader
autoconf
Expand Down
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@ def no_cythonize(extensions, **_ignore):
sources = [x for x in sources if not x.endswith(('htsfile.c', 'tabix.c', 'bgzip.c'))]
sources.append('cyvcf2/helpers.c')

extra_libs = []
if platform.system() != 'Darwin':
extra_libs.append('crypt')
if bool(int(os.getenv("LIBDEFLATE", 0))):
extra_libs.append('deflate')

extensions = [Extension("cyvcf2.cyvcf2",
["cyvcf2/cyvcf2.pyx"] + sources,
libraries=['z', 'bz2', 'lzma', 'curl', 'ssl'] + (['crypt'] if platform.system() != 'Darwin' else []),
libraries=['z', 'bz2', 'lzma', 'curl', 'ssl'] + extra_libs,
extra_compile_args=["-Wno-sign-compare", "-Wno-unused-function",
"-Wno-strict-prototypes",
"-Wno-unused-result", "-Wno-discarded-qualifiers"],
Expand Down

0 comments on commit b339e1b

Please sign in to comment.