Package: src:openbabel
Version: 3.2.0+dfsg-1
User: [email protected]
Usertags: python3.15
Tags: patch, ftbfs, forky, sid
Severity: important

Hi!

While rebuilding the python related packages against the Python 3.15rc2
version we found that openbabel only builds against the default Python
version.

This is a problem because it doesn't build the module for Python 3.15,
making packages that depend on it also unable to build for Python 3.15
(for example python-emmet-core).

To fix this, I've made a change that makes openbabel build against all
supported Python versions.

I've applied the fix in the sandbox [1] to verify that both openbabel
and the packages that depend on it build successfully. Please consider
applying the patch to support the upcoming 3.15 version.

Setting the severity to important for now. Once Python 3.15 is released,
it will be added to python3-defaults and this bug will become release
critical.

Happy hacking,

[1]: https://debusine.debian.net/debian/r-python-python3.15/

--
"Can you imagine what I would do if I could do all I can?" -- Sun Tzu
Saludos /\/\ /\ >< `/
diff --git a/debian/changelog b/debian/changelog
index 7c6a99d28..374b70963 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+openbabel (3.2.0+dfsg-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Build python extensions for all supported python3 versions.
+
+ -- Maximiliano Curia <[email protected]>  Fri, 18 Sep 2026 10:20:00 +0200
+
 openbabel (3.2.0+dfsg-1) unstable; urgency=medium
 
   * Upload to unstable
diff --git a/debian/control b/debian/control
index 9be254797..3b4ae39d1 100644
--- a/debian/control
+++ b/debian/control
@@ -22,7 +22,7 @@ Build-Depends: cmake,
                libxml2-dev,
                pkgconf,
                python3-all,
-               python3-dev,
+               python3-all-dev,
                python3-setuptools,
                rapidjson-dev,
                swig,
diff --git a/debian/rules b/debian/rules
index 664aae696..902d39ba4 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,6 +1,7 @@
 #!/usr/bin/make -f
 
--include /usr/share/python3/python.mk
+include /usr/share/dpkg/architecture.mk
+include /usr/share/dpkg/buildtools.mk
 
 DEB_BUILD_PARALLEL ?= $(shell guess_concurrency --require-mem 16G)
 export PYBUILD_TEST_ARGS=-n $(DEB_BUILD_PARALLEL)
@@ -16,6 +17,7 @@ export LDFLAGS      := $(shell dpkg-buildflags --get LDFLAGS)
 DH_AUTO_CONFIGURE_OPTS := -DCMAKE_BUILD_TYPE=None \
                           -DLIB_SUFFIX=/$(DEB_HOST_MULTIARCH) \
                           -DPYTHON_BINDINGS=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 \
+                          -DPYTHON_INSTDIR=/usr/lib/python3/dist-packages \
                           -DPERL_BINDINGS=ON \
                           -DOBPERL_INSTALLDIRS=vendor \
                           -DRUN_SWIG=ON \
@@ -36,9 +38,26 @@ override_dh_auto_configure:
 override_dh_auto_build:
 	dh_auto_build
 	make -C $(CURDIR)/builddir docs
+	mkdir -p $(CURDIR)/builddir/scripts
+	for pyversion in $(PYVERS); do \
+		pyinclude=$$(python$$pyversion -c "import sysconfig; print(sysconfig.get_path('include'))"); \
+		extsuffix=$$(python$$pyversion -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))"); \
+		$(CXX) $(CXXFLAGS) $(CPPFLAGS) -fPIC -shared \
+			-I$(CURDIR)/include -I$(CURDIR)/builddir/include -I/usr/include/eigen3 -I$$pyinclude \
+			-Wno-deprecated-declarations \
+			$(CURDIR)/scripts/python/openbabel/openbabel-python.cpp \
+			-o $(CURDIR)/builddir/scripts/_openbabel$$extsuffix \
+			$(LDFLAGS) -L$(CURDIR)/builddir/lib/$(DEB_HOST_MULTIARCH) -L$(CURDIR)/builddir/lib -lopenbabel; \
+	done
 
 override_dh_auto_install:
 	dh_auto_install
+	rm -f $(CURDIR)/debian/tmp/usr/lib/python3/dist-packages/openbabel/_openbabel.so
+	for pyversion in $(PYVERS); do \
+		extsuffix=$$(python$$pyversion -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))"); \
+		install -m 0644 $(CURDIR)/builddir/scripts/_openbabel$$extsuffix \
+			$(CURDIR)/debian/tmp/usr/lib/python3/dist-packages/openbabel/; \
+	done
 	mkdir --parents $(CURDIR)/debian/tmp/$(PERL_ARCHLIB)
 	mv debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/auto debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/Chemistry \
 		$(CURDIR)/debian/tmp/$(PERL_ARCHLIB)
diff --git a/debian/tests/control b/debian/tests/control
index 9fd0b8bc5..316f90bc0 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,6 +1,7 @@
 Tests: python3
 Depends:
  @,
+ python3-all
 Restrictions:
  allow-stderr,
  rw-build-tree,
diff --git a/debian/tests/python3 b/debian/tests/python3
index 823e85705..b9f2faf53 100644
--- a/debian/tests/python3
+++ b/debian/tests/python3
@@ -6,46 +6,48 @@ sed -i 's/"\.\."/"\/usr"/' test/testbabel.py
 
 arch=$(dpkg --print-architecture)
 fails=
-for TEST in test/test*.py
-do
-    fail_on_failure=true
-    case $TEST in
-      test/testroundtrip.py)
-        # timesout?
-        echo "Skipping ${TEST} ..."
-        continue;;
-      test/testdistgeom.py)
-	# timesout and exhausts memory
-	echo "Skipping ${TEST} ..."
-	continue;;
-      test/testbindings.py)
-        case "$arch" in
-          amd64)
-            true;;
-          *)
-            fail_on_failure=false;;
-        esac;;
-      test/testsym.py)
-          # on most/all non-amd64 architecture it fails
-          # if it finishes at all, it takes a very long time
-          # on worker13, the test takes 1000 times longer than on other amd64 hosts
-          echo "Skipping ${TEST} ..."
-          continue;;
-      test/testobconv_writers.py)
-        case "$arch" in arm64|i386|ppc64el|s390x)
-          fail_on_failure=false;;
-        esac;;
-    esac
-    echo "Running ${TEST} ..."
-    if python3 ${TEST}; then
-	:
-    else
-       if [ $fail_on_failure = "false" ] ; then
-         echo "Ignoring ${TEST} on $arch ..."
-       else
-         fails="$fails $TEST"
-       fi
-    fi
+for pyversion in $(py3versions -s); do
+    for TEST in test/test*.py
+    do
+        fail_on_failure=true
+        case $TEST in
+          test/testroundtrip.py)
+            # timesout?
+            echo "Skipping ${TEST} ..."
+            continue;;
+          test/testdistgeom.py)
+	    # timesout and exhausts memory
+	    echo "Skipping ${TEST} ..."
+	    continue;;
+          test/testbindings.py)
+            case "$arch" in
+              amd64)
+                true;;
+              *)
+                fail_on_failure=false;;
+            esac;;
+          test/testsym.py)
+              # on most/all non-amd64 architecture it fails
+              # if it finishes at all, it takes a very long time
+              # on worker13, the test takes 1000 times longer than on other amd64 hosts
+              echo "Skipping ${TEST} ..."
+              continue;;
+          test/testobconv_writers.py)
+            case "$arch" in arm64|i386|ppc64el|s390x)
+              fail_on_failure=false;;
+            esac;;
+        esac
+        echo "Running ${TEST} with ${pyversion} ..."
+        if ${pyversion} ${TEST}; then
+	    :
+        else
+           if [ $fail_on_failure = "false" ] ; then
+             echo "Ignoring ${TEST} on $arch with ${pyversion} ..."
+           else
+             fails="$fails ${TEST}(${pyversion})"
+           fi
+        fi
+    done
 done
 
 if [ -n "$fails" ]; then

Reply via email to