From ae165c388ec6e990b1b8caf4f0ac5b1e986b43da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org>
Date: Sat, 18 Jun 2011 19:47:28 +0200
Subject: [PATCH] disable PyDist feature if dh sequencer is invoked --with
 pydeb (closes: 630502, thanks to Gediminas Paulauskas for the original patch)

---
 debian/changelog | 2 ++
 dh_python2       | 9 ++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 53aaa52..91c9e4c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -15,6 +15,8 @@ python-defaults (2.7.2-2) UNRELEASED; urgency=low
     - add --ignore-namespace option that will disable handling
       Egg-info's namespace_packages.txt (AKA namespace feature)
     - PyDist: update dist_fallback file (with atypical Debian package names)
+    - disable PyDist feature if dh sequencer is invoked --with pydeb
+      (closes: 630502, thanks to Gediminas Paulauskas for the original patch)
 
  -- Piotr Ożarowski <piotr@debian.org>  Sun, 12 Jun 2011 13:28:48 +0200
 
diff --git a/dh_python2 b/dh_python2
index 33a922e..9d4d457 100755
--- a/dh_python2
+++ b/dh_python2
@@ -521,7 +521,9 @@ def main():
         except IOError:
             log.warning('cannot open debian/rules file')
         else:
-            if re.compile('\n\s*dh_pydeb').search(fp.read()):
+            rules = fp.read()
+            if re.search('\n\s*dh_pydeb', rules) or \
+               re.search('\n\s*dh\s+[^#]*--with\s+pydeb', rules):
                 log.warning('dh_pydeb detected, PyDist feature disabled')
                 options.guess_deps = False
 
@@ -646,6 +648,11 @@ def main():
             with open(join(dstdir, package), 'a') as fp:
                 fp.writelines("%s\n" % i for i in nsp)
 
+        pyshared = join('debian', package, 'usr/share/pyshared/')
+        if not os.listdir(pyshared):
+            # remove empty pyshared directory
+            os.rmdir(pyshared)
+
     dh.save()
 
 if __name__ == '__main__':
-- 
GitLab