From 58721a31e344a9b0def4ff48625a1001a0281294 Mon Sep 17 00:00:00 2001
From: SVN-Git Migration <python-modules-team@lists.alioth.debian.org>
Date: Thu, 8 Oct 2015 14:09:59 -0700
Subject: use_pybuild_buildsystem

Patch-Name: use_pybuild_buildsystem.patch
---
 stdeb/util.py | 96 +++++------------------------------------------------------
 1 file changed, 8 insertions(+), 88 deletions(-)

--- a/stdeb/util.py
+++ b/stdeb/util.py
@@ -865,7 +865,7 @@
         self.uploaders = parse_vals(cfg, module_name, 'Uploaders')
         self.date822 = get_date_822()
 
-        build_deps = []
+        build_deps = ['dh-python']
         if use_setuptools:
             if with_python2:
                 build_deps.append('python-setuptools (>= 0.6b3)')
@@ -1151,52 +1151,10 @@
         else:
             self.install_prefix = ''
 
-        rules_override_clean_target_pythons = []
-        rules_override_build_target_pythons = []
-        rules_override_install_target_pythons = []
-        if with_python2:
-            rules_override_clean_target_pythons.append(
-                RULES_OVERRIDE_CLEAN_TARGET_PY2 % self.__dict__
-                )
-            rules_override_build_target_pythons.append(
-                RULES_OVERRIDE_BUILD_TARGET_PY2 % self.__dict__
-                )
-            rules_override_install_target_pythons.append(
-                RULES_OVERRIDE_INSTALL_TARGET_PY2 % self.__dict__
-                )
-        if with_python3:
-            rules_override_clean_target_pythons.append(
-                RULES_OVERRIDE_CLEAN_TARGET_PY3 % self.__dict__
-                )
-            rules_override_build_target_pythons.append(
-                RULES_OVERRIDE_BUILD_TARGET_PY3 % self.__dict__
-                )
-            rules_override_install_target_pythons.append(
-                RULES_OVERRIDE_INSTALL_TARGET_PY3 % self.__dict__
-                )
-        self.rules_override_clean_target_pythons = \
-            '\n'.join(rules_override_clean_target_pythons)
-        self.rules_override_build_target_pythons = \
-            '\n'.join(rules_override_build_target_pythons)
-        self.rules_override_install_target_pythons = \
-            '\n'.join(rules_override_install_target_pythons)
-
-        self.override_dh_auto_clean = \
-            RULES_OVERRIDE_CLEAN_TARGET % self.__dict__
-        self.override_dh_auto_build = \
-            RULES_OVERRIDE_BUILD_TARGET % self.__dict__
-        self.override_dh_auto_install = \
-            RULES_OVERRIDE_INSTALL_TARGET % self.__dict__
-
-        scripts = ''
-        if with_python2 and python2_depends_name:
-            scripts = (
-                '        sed -i ' +
-                r'"s/\([ =]\)python[0-9]\?\(\(:any\)\? (\)/\\1%s\\2/g" ' +
-                'debian/%s.substvars') % (python2_depends_name, self.package)
-        self.override_dh_python2 = RULES_OVERRIDE_PYTHON2 % {
-            'scripts': scripts
-        }
+        if self.scripts_cleanup:
+            self.override_dh_auto_install = RULES_OVERRIDE_INSTALL_TARGET%self.__dict__
+        else:
+            self.override_dh_auto_install = ''
 
         if force_x_python3_version and with_python3 and x_python3_version and \
                 x_python3_version[0]:
@@ -1205,15 +1163,6 @@
             version = x_python3_version[0]
             if not version.endswith('~'):
                 version += '~'
-            self.override_dh_python3 = RULES_OVERRIDE_PYTHON3 % {
-                'scripts': (
-                    '        sed -i ' +
-                    r'"s/\([ =]python3:any (\)>= [^)]*\()\)/\\1%s\\2/g" ' +
-                    'debian/%s.substvars') % (version, self.package3)
-            }
-        else:
-            self.override_dh_python3 = ''
-
         sequencer_options = ['--with '+','.join(sequencer_with)]
 
         if with_dh_virtualenv:
@@ -1226,7 +1175,7 @@
 
             sequencer_options.append('--with python-virtualenv')
         else:
-            sequencer_options.append('--buildsystem=python_distutils')
+            sequencer_options.append('--buildsystem=pybuild')
             self.override_dh_virtualenv_py = ''
 
         if with_dh_systemd:
@@ -1235,7 +1184,7 @@
         self.sequencer_options = ' '.join(sequencer_options)
 
         setup_env_vars = parse_vals(cfg, module_name, 'Setup-Env-Vars')
-        self.exports = ""
+        self.exports = "export PYBUILD_NAME=%s" % self.source
         if len(setup_env_vars):
             self.exports += '\n'
             self.exports += '#exports specified using stdeb Setup-Env-Vars:\n'
@@ -1477,10 +1426,6 @@
     fd.write('3.0 (quilt)\n')
     fd.close()
 
-    fd = open(os.path.join(debian_dir, 'source', 'options'), mode='w')
-    fd.write(r'extend-diff-ignore="\.egg-info$"')
-    fd.close()
-
     if debian_dir_only:
         return
 
@@ -1626,75 +1571,16 @@
 %(percent_symbol)s:
         dh $@ %(sequencer_options)s
 
-%(override_dh_auto_clean)s
-
-%(override_dh_auto_build)s
-
-%(override_dh_auto_install)s
-
-%(override_dh_python2)s
-
-%(override_dh_python3)s
-
-%(override_dh_virtualenv_py)s
-
 %(binary_target_lines)s
 """
 
-RULES_OVERRIDE_CLEAN_TARGET_PY2 = "        python setup.py clean -a"
-RULES_OVERRIDE_CLEAN_TARGET_PY3 = "        python3 setup.py clean -a"
-RULES_OVERRIDE_CLEAN_TARGET = r"""
-override_dh_auto_clean:
-%(rules_override_clean_target_pythons)s
-        find . -name \*.pyc -exec rm {} \;
-"""
-
-RULES_OVERRIDE_BUILD_TARGET_PY2 = "        python setup.py build --force"
-RULES_OVERRIDE_BUILD_TARGET_PY3 = "        python3 setup.py build --force"
-RULES_OVERRIDE_BUILD_TARGET = """
-override_dh_auto_build:
-%(rules_override_build_target_pythons)s
-"""
-
-RULES_OVERRIDE_INSTALL_TARGET_PY2 = "        python setup.py install --force --root=debian/%(package)s --no-compile -O0 --install-layout=deb %(install_prefix)s %(no_python2_scripts_cli_args)s"  # noqa: E501
-
-RULES_OVERRIDE_INSTALL_TARGET_PY3 = "        python3 setup.py install --force --root=debian/%(package3)s --no-compile -O0 --install-layout=deb %(install_prefix)s %(no_python3_scripts_cli_args)s"  # noqa: E501
 
 RULES_OVERRIDE_INSTALL_TARGET = """
 override_dh_auto_install:
-%(rules_override_install_target_pythons)s
+    dh_auto_install
 %(scripts_cleanup)s
 """
 
-RULES_OVERRIDE_PYTHON2 = """
-override_dh_python2:
-        dh_python2 --no-guessing-versions
-%(scripts)s
-"""
-RULES_OVERRIDE_PYTHON3 = """
-override_dh_python3:
-        dh_python3
-%(scripts)s
-"""
-
-RULES_OVERRIDE_DH_VIRTUALENV_PY2 = """
-override_dh_virtualenv:
-        dh_virtualenv --python python2
-"""
-
-RULES_OVERRIDE_DH_VIRTUALENV_PY3 = """
-override_dh_virtualenv:
-        dh_virtualenv --python python3
-"""
-
-RULES_BINARY_TARGET = """
-binary: binary-arch binary-indep
-"""
-
-RULES_BINARY_ALL_TARGET = """
-binary: binary-indep
-"""
-
 RULES_BINARY_ARCH_TARGET = """
 binary-arch: build
 %(dh_binary_arch_lines)s
