From 12bd98f2f5a23df630e5998e0a48da81b78ce543 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org>
Date: Sun, 25 Jul 2010 12:36:34 +0200
Subject: [PATCH] add --recommend and --suggest command line options

---
 debian/changelog                 |  8 ++++----
 debpython/depends.py             |  8 ++++++++
 dh_python2                       | 13 ++++++++++---
 tests/t1/debian/pydist-overrides |  2 ++
 tests/t1/debian/rules            |  6 +++++-
 5 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index a8f05a0..e9d53a6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,13 +1,13 @@
-python-defaults (2.6.5-10) UNRELEASED; urgency=low
+python-defaults (2.6.5-10) unstable; urgency=low
 
   * dh_python2:
-    - add --depend command line option (use it if requires.txt
-      doesn't contain dependency that package needs)
+    - add --depend, --recommend and --suggest command line options
+     (use it if requires.txt doesn't contain dependency that package needs)
     - add {/usr,}/sbin to the list of directories with checked shebangs
   * pycompile: do not exit before all background byte compilation is finished
     (closes: 590224)
 
- -- Piotr Ożarowski <piotr@debian.org>  Wed, 21 Jul 2010 21:10:19 +0200
+ -- Piotr Ożarowski <piotr@debian.org>  Sun, 25 Jul 2010 12:34:56 +0200
 
 python-defaults (2.6.5-9) unstable; urgency=low
 
diff --git a/debpython/depends.py b/debpython/depends.py
index 4505ff9..a7afbf5 100644
--- a/debpython/depends.py
+++ b/debpython/depends.py
@@ -150,11 +150,19 @@ class Dependencies(object):
 
         if options.guess_deps:
             for fn in stats['requires.txt']:
+                # TODO: should options.recommends and options.suggests be
+                # removed from requires.txt?
                 for i in parse_pydep(fn):
                     self.depend(i)
 
         # add dependencies from --depend
         for item in options.depends:
             self.depend(guess_dependency(item))
+        # add dependencies from --recommend
+        for item in options.recommends:
+            self.recommend(guess_dependency(item))
+        # add dependencies from --suggest
+        for item in options.suggests:
+            self.suggest(guess_dependency(item))
 
         log.debug(self)
diff --git a/dh_python2 b/dh_python2
index e159635..a13821d 100755
--- a/dh_python2
+++ b/dh_python2
@@ -418,9 +418,16 @@ def main():
     parser.add_option('-X', '--exclude', action='append', dest='regexpr',
         help='exclude items that match given REGEXPR. You may use this option'
              'multiple times to build up a list of things to exclude.')
-    parser.add_option('--depend', action='append',
-        dest='depends', help='generate dependencies for given '
-                             'Python distributions')
+    parser.add_option('--depend', action='append', dest='depends',
+        help='translate given requirements into Debian dependencies '
+             'and add them to ${python:Depends}. '
+             'Use it for missing items in requires.txt.')
+    parser.add_option('--recommend', action='append', dest='recommends',
+        help='translate given requirements into Debian '
+             'dependencies and add them to ${python:Recommends}')
+    parser.add_option('--suggest', action='append', dest='suggests',
+        help='translate given requirements into Debian '
+             'dependencies and add them to ${python:Suggests}')
     # ignore some debhelper options:
     parser.add_option('-O', help=SUPPRESS_HELP)
 
diff --git a/tests/t1/debian/pydist-overrides b/tests/t1/debian/pydist-overrides
index 24b440d..f5800e4 100644
--- a/tests/t1/debian/pydist-overrides
+++ b/tests/t1/debian/pydist-overrides
@@ -1,2 +1,4 @@
 Mako python-mako (>= 0.2)
 SQLAlchemy python-sqlalchemy (>= 0.6)
+Foo python-foo
+Bar python-bar
diff --git a/tests/t1/debian/rules b/tests/t1/debian/rules
index 3a17902..c8af0ac 100755
--- a/tests/t1/debian/rules
+++ b/tests/t1/debian/rules
@@ -5,4 +5,8 @@
 override_dh_pysupport:
 	find debian/ -name jquery.js -exec \
 	ln -fs /usr/share/javascript/jquery/jquery.js '{}' \;
-	DH_VERBOSE=1 ../../dh_python2 --depend 'SQLAlchemy >= 0.6.1'
+	DH_VERBOSE=1 ../../dh_python2\
+		--depend 'SQLAlchemy >= 0.6.1'\
+		--recommend Mako\
+		--suggest 'Foo >= 0.1'\
+		--suggest 'bar >= 1.0'
-- 
GitLab