[med-svn] [Git][med-team/python-pyhmmer][master] Link the extensions against the packaged HMMER and Easel libraries

Andreas Tille (@tille) gitlab at salsa.debian.org
Mon Nov 16 10:39:56 GMT 2026



Andreas Tille pushed to branch master at Debian Med / python-pyhmmer


Commits:
708b19d8 by Andreas Tille at 2026-11-16T11:25:07+01:00
Link the extensions against the packaged HMMER and Easel libraries

Build with PYHMMER_USE_SYSTEM_LIBS=ON, which makes CMake locate the
HMMER and Easel libraries through pkg-config and link the Cython
extension modules against them instead of compiling the copies vendored
in the upstream tarball.  The binary package therefore does not ship
private copies of libhmmer/libeasel any more.

Add the versioned Build-Depends on libhmmer-dev and libeasel-dev that
provide the exported symbols pyhmmer needs, and replace the autodep8
test with a Debian Med style run-unit-test script which runs the
upstream unit tests, checks with ldd that the extensions are really
linked against the packaged shared libraries, and finally runs a small
end-to-end hmmsearch example.

- - - - -


7 changed files:

- debian/changelog
- debian/control
- + debian/patches/0002-Link-against-the-system-HMMER-and-Easel-libraries.patch
- debian/patches/series
- debian/rules
- debian/tests/control
- + debian/tests/run-unit-test


Changes:

=====================================
debian/changelog
=====================================
@@ -1,5 +1,12 @@
 python-pyhmmer (0.12.3-1) UNRELEASED; urgency=medium
 
   * Initial release (Closes: #XXX).
+  * Link the extension modules against the Debian-packaged HMMER and Easel
+    libraries (libhmmer-dev from the hmmer source package and libeasel-dev
+    from the easel source package) instead of compiling the copies bundled
+    in the upstream tarball.
+  * Move the autopkgtest to a Debian Med style run-unit-test script, and
+    additionally check that the extensions are dynamically linked against
+    libhmmer/libeasel and run a small hmmsearch example.
 
  -- Andreas Tille <tille at debian.org>  Wed, 11 Nov 2026 14:30:00 +0100


=====================================
debian/control
=====================================
@@ -7,13 +7,15 @@ Build-Depends: cmake,
                cython3,
                debhelper-compat (= 14),
                dh-sequence-python3,
+               libeasel-dev (>= 0.49+dfsg-2),
+               libhmmer-dev (>= 3.4+dfsg2-1),
                ninja-build,
+               pkgconf,
                pybuild-plugin-pyproject,
                python3-all-dev,
                python3-numpy,
                python3-psutil,
                python3-scikit-build-core,
-Testsuite: autopkgtest-pkg-python
 Vcs-Browser: https://salsa.debian.org/med-team/python-pyhmmer
 Vcs-Git: https://salsa.debian.org/med-team/python-pyhmmer.git
 Homepage: https://github.com/althonos/pyhmmer


=====================================
debian/patches/0002-Link-against-the-system-HMMER-and-Easel-libraries.patch
=====================================
@@ -0,0 +1,70 @@
+Description: Link against the system HMMER and Easel libraries
+ Add a PYHMMER_USE_SYSTEM_LIBS CMake option which, when enabled, detects the
+ HMMER and Easel libraries installed on the system through pkg-config and
+ links the Cython extension modules against them instead of compiling the
+ copies vendored in vendor/hmmer and vendor/easel.
+ .
+ The Debian package enables this option so that python3-pyhmmer uses the
+ libraries shipped by the hmmer source package rather than bundling its own
+ copy.
+Forwarded: not-needed
+Author: Andreas Tille <tille at debian.org>
+Last-Update: 2026-11-11
+Assisted-By: DeepSeek V4.1 Flash Free
+---
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 0aed183..bab59f8 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -3,6 +3,20 @@ project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES C)
+ 
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+ 
++# --- Locate the HMMER and Easel libraries -------------------------------------
++# When enabled, the Cython extension modules are linked against the HMMER and
++# Easel libraries installed on the system (detected through pkg-config)
++# instead of the copies vendored in `vendor/`.
++
++option(PYHMMER_USE_SYSTEM_LIBS
++    "Link against system-installed HMMER and Easel libraries" OFF)
++if(PYHMMER_USE_SYSTEM_LIBS)
++    find_package(PkgConfig REQUIRED)
++    pkg_check_modules(PYHMMER_SYSTEM_HMMER REQUIRED IMPORTED_TARGET hmmer)
++    pkg_check_modules(PYHMMER_SYSTEM_EASEL REQUIRED IMPORTED_TARGET easel)
++    message(STATUS "Using system HMMER and Easel libraries")
++endif()
++
+ set_property(GLOBAL PROPERTY PYTHON_EXTENSIONS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
+ 
+ # --- Detect SIMD --------------------------------------------------------------
+diff --git a/pyproject.toml b/pyproject.toml
+index d7e874a..1466d45 100644
+--- a/pyproject.toml
++++ b/pyproject.toml
+@@ -77,6 +77,7 @@ sdist.exclude = [
+ [tool.scikit-build.cmake.define]
+ PYHMMER_INSTALL_LIBS = { env = "PYHMMER_INSTALL_LIBS", default = true }
+ BUILD_SHARED_LIBS = { env = "BUILD_SHARED_LIBS", default = true }
++PYHMMER_USE_SYSTEM_LIBS = { env = "PYHMMER_USE_SYSTEM_LIBS", default = true }
+ 
+ [[tool.scikit-build.generate]]
+ path = "src/pyhmmer/_version.py"
+diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
+index 5d0a3bf..bc04432 100644
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -1,4 +1,12 @@
+ add_subdirectory(cmake)
+-add_subdirectory(easel)
+-add_subdirectory(hmmer)
++
++if(PYHMMER_USE_SYSTEM_LIBS)
++    add_library(libeasel INTERFACE)
++    target_link_libraries(libeasel INTERFACE PkgConfig::PYHMMER_SYSTEM_EASEL)
++    add_library(libhmmer INTERFACE)
++    target_link_libraries(libhmmer INTERFACE PkgConfig::PYHMMER_SYSTEM_HMMER)
++else()
++    add_subdirectory(easel)
++    add_subdirectory(hmmer)
++endif()
+ add_subdirectory(pyhmmer)


=====================================
debian/patches/series
=====================================
@@ -1 +1,2 @@
 0001-Do-not-install-CMake-package-files-without-libraries.patch
+0002-Link-against-the-system-HMMER-and-Easel-libraries.patch


=====================================
debian/rules
=====================================
@@ -3,11 +3,13 @@
 export DH_VERBOSE = 1
 export PYBUILD_NAME = pyhmmer
 
-# Link the bundled HMMER and Easel code statically into the extension
-# modules instead of installing private shared libraries, so that no
-# copies of the libraries have to be shipped in the binary package.
+# Do not ship private copies of the HMMER/Easel shared libraries: the
+# extension modules are linked against the Debian-packaged libhmmer and
+# libeasel instead (see debian/patches/0002-*).  BUILD_SHARED_LIBS is only
+# a fallback for the vendored build.
 export BUILD_SHARED_LIBS = OFF
 export PYHMMER_INSTALL_LIBS = OFF
+export PYHMMER_USE_SYSTEM_LIBS = ON
 
 %:
 	dh $@ --buildsystem=pybuild


=====================================
debian/tests/control
=====================================
@@ -1,3 +1,3 @@
+Tests: run-unit-test
 Depends: @, python3-numpy
 Restrictions: allow-stderr
-Test-Command: python3 -m unittest pyhmmer.tests -v


=====================================
debian/tests/run-unit-test
=====================================
@@ -0,0 +1,44 @@
+#!/bin/bash
+# Run the pyhmmer unit tests and a small end-to-end search example.
+set -eu
+
+pkg="pyhmmer"
+
+if [ -z "${AUTOPKGTEST_TMP:-}" ] ; then
+    AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
+fi
+cd "${AUTOPKGTEST_TMP}"
+
+echo "==> running the pyhmmer unit tests"
+python3 -m unittest pyhmmer.tests -v
+
+echo "==> checking that the extensions use the Debian-packaged libraries"
+python3 - <<'EOF'
+import subprocess
+import pyhmmer.plan7
+
+linked = subprocess.check_output(["ldd", pyhmmer.plan7.__file__], text=True)
+for library in ("libhmmer.so.3", "libeasel.so.0"):
+    assert library in linked, f"{library} not linked:\n{linked}"
+print("plan7 extension is dynamically linked against libhmmer and libeasel")
+EOF
+
+echo "==> running a small hmmsearch example"
+python3 - <<'EOF'
+from importlib.resources import files
+
+import pyhmmer
+from pyhmmer.easel import SequenceFile
+from pyhmmer.plan7 import HMMFile
+
+data = files("pyhmmer.tests").joinpath("data")
+with HMMFile(str(data.joinpath("hmms", "txt", "Thioesterase.hmm"))) as hmm_file:
+    hmm = hmm_file.read()
+with SequenceFile(str(data.joinpath("seqs", "938293.PRJEB85.HG003687.faa")), digital=True) as seqs_file:
+    sequences = seqs_file.read_block()
+
+hits = list(pyhmmer.hmmsearch(hmm, sequences, cpus=1))[0]
+assert len(hits) == 1, f"expected 1 hit, got {len(hits)}"
+assert hits[0].name == "938293.PRJEB85.HG003687_113"
+print(f"hmmsearch found {hits[0].name}: score={hits[0].score:.1f} bits")
+EOF



View it on GitLab: https://salsa.debian.org/med-team/python-pyhmmer/-/commit/708b19d8689795f3f0738f20f32126ce54da5eb1

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-pyhmmer/-/commit/708b19d8689795f3f0738f20f32126ce54da5eb1
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20261116/700fc4b8/attachment-0001.htm>


More information about the debian-med-commit mailing list