diff --git a/debian/changelog b/debian/changelog
index 53aaa52f04b84015f4a67ec8f2c42cdbd2edde94..91c9e4c47be7d71d4f82add694e9f9dcaf53f5c4 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 33a922e35e2d8c6f38b384ffd3431da05098770a..9d4d457d71d2f97ef966333293dce2ce87b4c984 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__':