Source: dh-python
Version: 4.20191017
Tags: patch
User: debian-cr...@lists.debian.org
Usertags: ftcbfs
Control: affects -1 + src:tlsh

When cross building python extensions, one is supposed to export a
_PYTHON_SYSCONFIGDATA_NAME. Unfortunately, it contains the abi and from
3.7 to 3.8 we changed the abi. Now the _PYTHON_SYSCONFIGDATA_NAME is
version-dependent. Please update pybuild to issue the correct
_PYTHON_SYSCONFIGDATA_NAME for 3.8.

This breaks any package that tries to cross build a python extension for
python 3.8 such as tlsh. Likely more.

Helmut
diff --minimal -Nru dh-python-4.20191017/debian/changelog 
dh-python-4.20191017+nmu1/debian/changelog
--- dh-python-4.20191017/debian/changelog       2019-10-17 22:26:10.000000000 
+0200
+++ dh-python-4.20191017+nmu1/debian/changelog  2020-03-01 07:28:11.000000000 
+0100
@@ -1,3 +1,10 @@
+dh-python (4.20191017+nmu1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix _PYTHON_SYSCONFIGDATA_NAME for 3.8. (Closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Sun, 01 Mar 2020 07:28:11 +0100
+
 dh-python (4.20191017) unstable; urgency=medium
 
   * dh_python2: generate python2 dependencies instead of python ones
diff --minimal -Nru dh-python-4.20191017/dhpython/build/base.py 
dh-python-4.20191017+nmu1/dhpython/build/base.py
--- dh-python-4.20191017/dhpython/build/base.py 2018-09-26 00:20:40.000000000 
+0200
+++ dh-python-4.20191017+nmu1/dhpython/build/base.py    2020-03-01 
07:28:11.000000000 +0100
@@ -209,11 +209,11 @@
         if log_file is False and self.cfg.really_quiet:
             log_file = None
         command = command.format(**args)
+        env = dict(context['ENV'])
         if 'PYTHONPATH' in args:
-            env = dict(context['ENV'])
             env['PYTHONPATH'] = args['PYTHONPATH']
-        else:
-            env = context['ENV']
+        if '_PYTHON_SYSCONFIGDATA_NAME' in args:
+            env.setdefault('_PYTHON_SYSCONFIGDATA_NAME', 
args['_PYTHON_SYSCONFIGDATA_NAME'])
         log.info(command)
         return execute(command, context['dir'], env, log_file)
 
diff --minimal -Nru dh-python-4.20191017/pybuild 
dh-python-4.20191017+nmu1/pybuild
--- dh-python-4.20191017/pybuild        2019-03-07 21:51:51.000000000 +0100
+++ dh-python-4.20191017+nmu1/pybuild   2020-03-01 07:28:11.000000000 +0100
@@ -76,12 +76,6 @@
             '_PYTHON_HOST_PLATFORM',
             '{DEB_HOST_ARCH_OS}-{DEB_HOST_ARCH}'.format(**arch_data))
 
-        if arch_data['DEB_BUILD_ARCH'] != arch_data['DEB_HOST_ARCH']:
-            # support cross compiling Python 3.X extensions, see #892931
-            env.setdefault('_PYTHON_SYSCONFIGDATA_NAME',
-                           ('_sysconfigdata_m_{DEB_HOST_ARCH_OS}'
-                            '_{DEB_HOST_MULTIARCH}').format(**arch_data))
-
     if cfg.system:
         certainty = 99
         Plugin = build.plugins.get(cfg.system)
@@ -231,6 +225,13 @@
                          ).format(version, arch_data))
         args['PYTHONPATH'] = ':'.join(pp)
 
+        # support cross compiling Python 3.X extensions, see #892931
+        if (version.major >= 3 and
+            arch_data.get('DEB_BUILD_ARCH', ' ') != 
arch_data.get('DEB_HOST_ARCH')):
+            abi = '' if (version.major, version.minor) >= (3, 8) else 'm'
+            args['_PYTHON_SYSCONFIGDATA_NAME'] = \
+                
'_sysconfigdata_{abi}_{DEB_HOST_ARCH_OS}_{DEB_HOST_MULTIARCH}'.format(abi=abi, 
**arch_data)
+
         if not exists(args['build_dir']):
             makedirs(args['build_dir'])
 
@@ -256,11 +257,11 @@
     def run(func, interpreter, version, context):
         step = func.__func__.__name__
         args = get_args(context, step, version, interpreter)
+        env = dict(context['ENV'])
         if 'PYTHONPATH' in args:
-            env = dict(context['ENV'])
             env['PYTHONPATH'] = args['PYTHONPATH']
-        else:
-            env = context['ENV']
+        if '_PYTHON_SYSCONFIGDATA_NAME' in args:
+            env.setdefault('_PYTHON_SYSCONFIGDATA_NAME', 
args['_PYTHON_SYSCONFIGDATA_NAME'])
 
         before_cmd = get_option('before_{}'.format(step), interpreter, version)
         if before_cmd:

Reply via email to