Source: pysmbc
Version: 1.0.25.1-1
Tags: patch
User: [email protected]
Usertags: cross-satisfiability ftcbfs

pysmbc fails to cross build for a number of reasons.

On the surface, it's python3-pytest dependency is not satisfiable. One
would expect it to not be needed during cross builds and indeed,
annotating it <!nocheck> gets rid of it without affecting binary output.

Then, the python3-all-dev dependency needs to be converted for cross
compilation. It becomes "python3-all-dev:any, libpython3-all-dev".

Last but not least, setup.py hard codes the build architecture
pkg-config and therefore fails finding required packages. I propose
making it substitable via the environment and providing a suitable
substitution.

You may find all of the proposed changes in the attached debdiff. Once
applying it, pysmbc becomes cross buildable.

Helmut
diff --minimal -Nru pysmbc-1.0.25.1/debian/changelog 
pysmbc-1.0.25.1/debian/changelog
--- pysmbc-1.0.25.1/debian/changelog    2024-01-22 00:30:00.000000000 +0100
+++ pysmbc-1.0.25.1/debian/changelog    2025-05-11 16:47:31.000000000 +0200
@@ -1,3 +1,14 @@
+pysmbc (1.0.25.1-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix cross building. (Closes: #-1)
+    + Annotate python3-pytest dependency <!nocheck>.
+    + Multiarchify python Build-Depends.
+    + cross.patch: make pkg-config substitutable in setup.py
+    + Substitute PKG_CONFIG.
+
+ -- Helmut Grohne <[email protected]>  Sun, 11 May 2025 16:47:31 +0200
+
 pysmbc (1.0.25.1-1) unstable; urgency=medium
 
   * Team Upload
diff --minimal -Nru pysmbc-1.0.25.1/debian/control 
pysmbc-1.0.25.1/debian/control
--- pysmbc-1.0.25.1/debian/control      2024-01-22 00:30:00.000000000 +0100
+++ pysmbc-1.0.25.1/debian/control      2025-05-11 16:47:31.000000000 +0200
@@ -8,8 +8,9 @@
                dh-sequence-python3,
                python3-setuptools,
                pkgconf,
-               python3-pytest,
-               python3-all-dev,
+               python3-pytest <!nocheck>,
+               python3-all-dev:any,
+               libpython3-all-dev,
                libsmbclient-dev (>= 3.2)
 Standards-Version: 4.6.2
 Homepage: https://github.com/hamano/pysmbc
diff --minimal -Nru pysmbc-1.0.25.1/debian/patches/cross.patch 
pysmbc-1.0.25.1/debian/patches/cross.patch
--- pysmbc-1.0.25.1/debian/patches/cross.patch  1970-01-01 01:00:00.000000000 
+0100
+++ pysmbc-1.0.25.1/debian/patches/cross.patch  2025-05-11 16:47:31.000000000 
+0200
@@ -0,0 +1,44 @@
+--- pysmbc-1.0.25.1.orig/setup.py
++++ pysmbc-1.0.25.1/setup.py
+@@ -51,13 +51,18 @@
+ 
+ """
+ 
++import os
+ import subprocess
+ from setuptools import setup, Extension
+ 
++def pkgconfig(args):
++    p = os.environ.get("PKG_CONFIG", "pkg-config")
++    c = subprocess.Popen([p] + args, stdout=subprocess.PIPE)
++    return c.communicate()
++
+ def pkgconfig_I(pkg):
+     dirs = []
+-    c = subprocess.Popen(["pkg-config", "--cflags", pkg], 
stdout=subprocess.PIPE)
+-    (stdout, stderr) = c.communicate ()
++    (stdout, stderr) = pkgconfig(["--cflags", pkg])
+     for p in stdout.decode('ascii').split():
+         if p.startswith("-I"):
+             dirs.append(p[2:])
+@@ -65,8 +70,7 @@
+ 
+ def pkgconfig_L(pkg):
+     dirs = []
+-    c = subprocess.Popen(["pkg-config", "--libs", pkg], 
stdout=subprocess.PIPE)
+-    (stdout, stderr) = c.communicate ()
++    (stdout, stderr) = pkgconfig(["--libs", pkg])
+     for p in stdout.decode('ascii').split():
+         if p.startswith("-L"):
+             dirs.append(p[2:])
+@@ -75,9 +79,7 @@
+ def pkgconfig_Dversion(pkg, prefix=None):
+     if prefix is None:
+         prefix = pkg.upper() + '_'
+-    c = subprocess.Popen(["pkg-config", "--modversion", pkg],
+-                         stdout=subprocess.PIPE)
+-    (stdout, stderr) = c.communicate()
++    (stdout, stderr) = pkgconfig(["--modversion", pkg])
+     vers = stdout.decode('ascii').rstrip().split('.')
+     if len(vers) == 3:
+         ver = str(int(vers[0]) * 10000 + int(vers[1]) * 100 + int(vers[2]))
diff --minimal -Nru pysmbc-1.0.25.1/debian/patches/series 
pysmbc-1.0.25.1/debian/patches/series
--- pysmbc-1.0.25.1/debian/patches/series       1970-01-01 01:00:00.000000000 
+0100
+++ pysmbc-1.0.25.1/debian/patches/series       2025-05-11 16:47:31.000000000 
+0200
@@ -0,0 +1 @@
+cross.patch
diff --minimal -Nru pysmbc-1.0.25.1/debian/rules pysmbc-1.0.25.1/debian/rules
--- pysmbc-1.0.25.1/debian/rules        2024-01-22 00:30:00.000000000 +0100
+++ pysmbc-1.0.25.1/debian/rules        2025-05-11 16:47:31.000000000 +0200
@@ -2,6 +2,9 @@
 
 export PYBUILD_NAME=smbc
 
+include /usr/share/dpkg/buildtools.mk
+export PKG_CONFIG
+
 %:
        dh $@ --buildsystem=pybuild
 

Reply via email to