From 0594be34ccd2d0ad588e6c65ece1276bd8aacf51 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org>
Date: Tue, 7 Sep 2010 21:39:30 +0200
Subject: [PATCH] if dist_fallback and `dpkg -S` fails to find the right
 package name, fall back to package name recommended by Debian Python Policy
 (use debian/pydist-override file to override)

---
 debian/changelog                 |   3 +
 debpython/pydist.py              |  67 ++--
 pydist/Makefile                  |   2 +-
 pydist/README.PyDist             |   2 +
 pydist/dist_fallback             | 529 +------------------------------
 pydist/generate_fallback_list.py |  11 +
 tests/t1/debian/pydist-overrides |   1 +
 tests/t1/setup.py                |   2 +-
 8 files changed, 63 insertions(+), 554 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 118741a..1e89756 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,9 @@ python-defaults (2.6.6-2) UNRELEASED; urgency=low
     - add dist_fallback file with a list of Python distribution name and
       Debian package name pairs (to be used as a fall back source for
       PyDist feature)
+    - if dist_fallback and `dpkg -S` fails to find the right package name,
+      fall back to package name recommended by Debian Python Policy (use
+      debian/pydist-override file to override)
     - TODO: disable PyDist feature if dh_pydeb is in debian/rules
   * use /usr/bin/python rather than python in python-minimal.postinst
     (closes: 595826)
diff --git a/debpython/pydist.py b/debpython/pydist.py
index 7a51bb5..055d496 100644
--- a/debpython/pydist.py
+++ b/debpython/pydist.py
@@ -33,11 +33,11 @@ log = logging.getLogger('dh_python')
 PUBLIC_DIR_RE = re.compile(r'.*?/usr/lib/python(\d.\d+)/(site|dist)-packages')
 PYDIST_RE = re.compile(r"""
     (?P<name>[A-Za-z][A-Za-z0-9_.]*)             # Python distribution name
-    \s+
+    \s*
     (?P<vrange>(?:-?\d\.\d+(?:-(?:\d\.\d+)?)?)?) # version range
     \s*
-    (?P<dependency>[a-z][^;]*)                   # Debian dependency
-    (?: # optional upstream version -> Debian version translator
+    (?P<dependency>(?:[a-z][^;]*)?)              # Debian dependency
+    (?:  # optional upstream version -> Debian version translator
         ;\s*
         (?P<standard>PEP386)?                    # PEP-386 mode
         \s*
@@ -45,9 +45,11 @@ PYDIST_RE = re.compile(r"""
     )?
     """, re.VERBOSE)
 REQUIRES_RE = re.compile(r'''
-    (?P<name>[A-Za-z][A-Za-z0-9_.]*)
+    (?P<name>[A-Za-z][A-Za-z0-9_.]*)     # Python distribution name
+    \s*
+    (?P<enabled_extras>(?:\[[^\]]*\])?)  # ignored for now
     \s*
-    (?: # optional version
+    (?:  # optional minimum/maximum version
         (?P<operator><=?|>=?|==|!=)
         \s*
         (?P<version>(\w|[-.])+)
@@ -91,7 +93,11 @@ def load(dname='/usr/share/python/dist/', fname='debian/pydist-overrides',
                 line = line.strip('\r\n')
                 if line.startswith('#') or not line:
                     continue
-                dist = PYDIST_RE.search(line).groupdict()
+                dist = PYDIST_RE.search(line)
+                if not dist:
+                    log.error('%s file has a broken line: %s', fpath, line)
+                    exit(9)
+                dist = dist.groupdict()
                 name = safe_name(dist['name'])
                 dist['versions'] = get_requested_versions(dist['vrange'])
                 dist['dependency'] = dist['dependency'].strip()
@@ -116,10 +122,10 @@ def guess_dependency(req, version=None):
     data = load()
     req_dict = REQUIRES_RE.match(req)
     if not req_dict:
-        log.warning('requirement is not valid: %s', req)
+        log.error('requirement is not valid: %s', req)
         log.info('please ask dh_python2 author to fix REQUIRES_RE '
                  'or your upstream author to fix requires.txt')
-        return set()  # should we sys.exit(1) here?
+        exit(8)
     req_dict = req_dict.groupdict()
     details = data.get(req_dict['name'].lower())
     if details:
@@ -128,6 +134,8 @@ def guess_dependency(req, version=None):
                 # rule doesn't match version, try next one
                 continue
 
+            if not item['dependency']:
+                return  # this requirement should be ignored
             if item['dependency'].endswith(')'):
                 # no need to translate versions if version is hardcoded in Debian
                 # dependency
@@ -139,8 +147,7 @@ def guess_dependency(req, version=None):
                 return item['dependency']
 
     # try dpkg -S
-
-    query = "'%s-?*\.egg-info'" % name  # TODO: .dist-info
+    query = "'%s-?*\.egg-info'" % safe_name(name)  # TODO: .dist-info
     if version:
         query = "%s | grep '/python%s/\|/pyshared/'" % \
                 (query, vrepr(version))
@@ -151,22 +158,24 @@ def guess_dependency(req, version=None):
     process = Popen("/usr/bin/dpkg -S %s" % query, \
                     shell=True, stdout=PIPE)
     stdout, stderr = process.communicate()
-    if process.returncode != 0:
-        log.error('Cannot find package that provides %s. '
-                  'Please add it to debian/pydist-overrides', name)
-        log.info("hint: `apt-file search -x '(packages|pyshared)/" +\
-                  "%s' -l` might help", name)
-        exit(8)
+    if process.returncode == 0:
+        result = set()
+        for line in stdout.split('\n'):
+            if not line.strip():
+                continue
+            result.add(line.split(':')[0])
+        if len(result) > 1:
+            log.error('more than one package name found for %s dist', name)
+        else:
+            return result.pop()
 
-    result = set()
-    for line in stdout.split('\n'):
-        if not line.strip():
-            continue
-        result.add(line.split(':')[0])
-    if len(result) > 1:
-        log.error('more than one package name found for %s dist', name)
-        exit(9)
-    return result.pop()
+    # fall back to python-distname
+    pname = sensible_pname(name)
+    log.warn('Cannot find package that provides %s. '
+             'Using %s as package name. Please add "%s correct_package_name" '
+             'line to debian/pydist-overrides to override it.',
+             name, pname, name)
+    return pname
 
 
 def parse_pydep(fname):
@@ -193,3 +202,11 @@ def parse_pydep(fname):
 def safe_name(name):
     """Emulate distribute's safe_name."""
     return re.compile('[^A-Za-z0-9.]+').sub('_', name).lower()
+
+
+def sensible_pname(egg_name):
+    """Guess Debian package name from Egg name."""
+    egg_name = safe_name(egg_name).replace('_', '-')
+    if egg_name.startswith('python-'):
+        egg_name = egg_name[7:]
+    return "python-%s" % egg_name.lower()
diff --git a/pydist/Makefile b/pydist/Makefile
index 2daa7bc..d7f7131 100644
--- a/pydist/Makefile
+++ b/pydist/Makefile
@@ -6,7 +6,7 @@ clean:
 	rm -f README.PyDist.html
 
 dist_fallback:
-	python ./generate_fallback_list.py
+	python ./generate_fallback_list.py --skip-sensible-names
 
 README.PyDist.html:
 	rst2html README.PyDist README.PyDist.html
diff --git a/pydist/README.PyDist b/pydist/README.PyDist
index 9241fb0..36377ad 100644
--- a/pydist/README.PyDist
+++ b/pydist/README.PyDist
@@ -25,6 +25,7 @@ Examples:
 DEPENDENCY
 ``````````
 Debian dependency, multiple packages or versions are allowed.
+If not set, given Python distribution name will be ignored.
 
 Examples:
  * python-mako
@@ -77,5 +78,6 @@ Complete examples:
  * Mako python-mako; PEP386
  * foo -2.5 python-oldfoo; s/^/3:/
  * foo 2.5- python-foo; PEP386
+ * Bar 2.6-
 
 .. vim: ft=rst
diff --git a/pydist/dist_fallback b/pydist/dist_fallback
index a3fab3d..eb9c96d 100644
--- a/pydist/dist_fallback
+++ b/pydist/dist_fallback
@@ -1,68 +1,30 @@
 setuptools python-pkg-resources
-4Suite_XML python-4suite-xml
 AddOns python-peak.util
-Amara python-amara
-AppTools python-apptools
-AuthKit python-authkit
 AutoDockTools autodocktools
-Axiom python-axiom
 Babel python-pybabel
-Beaker python-beaker
-BeautifulSoup python-beautifulsoup
 BitTornado bittornado
 BitTorrent bittorrent
 Bitten trac-bitten
-Box2D python-box2d
-Brlapi python-brlapi
 Bugs_Everywhere bugs-everywhere
 BytecodeAssembler python-peak.util
 BzrPipeline bzr-pipeline
 BzrTools bzrtools
-CDDB python-cddb
-CMOR python-cmor
-Camelot python-camelot
-Catwalk python-catwalk
 CedarBackup2 cedar-backup2
-Cerealizer python-cerealizer
-Chaco python-chaco
-Chameleon python-chameleon
-Cheetah python-cheetah
-CherryPy python-cherrypy
-ClientForm python-clientform
+CherryPy python-cherrypy3
 Codeville codeville
-Coherence python-coherence
-CouchDB python-couchdb
-Creoleparser python-creoleparser
 Cython cython
 DITrack ditrack
-DSV python-dsv
 DebTorrent debtorrent
-DecoratorTools python-decoratortools
 DejaVu mgltools-dejavu
-DeliciousAPI python-deliciousapi
-Django python-django
 Djapian python-django-djapian
 Djblets python-django-djblets
 Dosage dosage
 DouF00 douf00
-EditObj python-editobj
 Editra editra
 Eikazo eikazo
-Elements python-elements
-Elixir python-elixir
-Enable python-enable
-EnthoughtBase python-enthoughtbase
-EnvisageCore python-envisagecore
-EnvisagePlugins python-envisageplugins
-Epsilon python-epsilon
 Extremes python-peak.util
-FFC python-ffc
-FIAT python-fiat
 Fabric fabric
-FibraNet python-fibranet
-Flask python-flask
 Fnorb fnorb
-GDAL python-gdal
 GGZChess python-ggz
 GGZCore python-ggz
 GGZDMod python-ggz
@@ -70,57 +32,26 @@ GGZMod python-ggz
 GNS3 gns3
 Gallery_Uploader gallery-uploader
 GaussSum gausssum
-Genetic python-genetic
-Genshi python-genshi
 GeoIP_Python python-geoip
-GnuPGInterface python-gnupginterface
 HarvestMan harvestman
 HijriApplet python-hijra
-IMDbPY python-imdbpy
-IPy python-ipy
 ISO8583_Module python-iso8583
 Ibid ibid
 JCC jcc
-JPype python-jpype
-Jinja python-jinja
-Jinja2 python-jinja2
-KWWidgets python-kwwidgets
 Loom bzr-loom
-Louie python-louie
-M2Crypto python-m2crypto
-MDP python-mdp
-MLPY python-mlpy
 Magic_file_extensions python-magic
-Mako python-mako
-MapScript python-mapscript
-Markdown python-markdown
-MarkupSafe python-markupsafe
 Mayavi mayavi2
-MiniMock python-minimock
 Mirage mirage
 Mnemosyne mnemosyne
 Model_Builder model-builder
 MolKit mgltools-molkit
 MySQL_python python-mysqldb
-Myghty python-myghty
-MyghtyUtils python-myghtyutils
 Nautilus_scripts_manager nautilus-scripts-manager
 NetworkEditor mgltools-networkeditor
-Nevow python-nevow
 Nulog nulog
-OcempGUI python-ocempgui
-Othman python-othman
-PAM python-pam
 PEAK_Rules python-peak.rules
 PIDA pida
-PLWM python-plwm
-Paste python-paste
-PasteDeploy python-pastedeploy
-PasteScript python-pastescript
-PasteWebKit python-pastewebkit
-Paver python-paver
 Photon photon
-Pivy python-pivy
 Pmv mgltools-pmv
 Pootle pootle
 Postr postr
@@ -132,66 +63,35 @@ PyAIML python-aiml
 PyAutoDock mgltools-pyautodock
 PyBabel mgltools-pybabel
 PyBluez python-bluez
-PyChart python-pychart
 PyChecker pychecker
 PyCoCuMa pycocuma
-PyGreSQL python-pygresql
-PyICU python-pyicu
-PyKCS11 python-pykcs11
-PyMTP python-pymtp
 PyMetrics pymetrics
-PyODE python-pyode
 PyOpenAL python-openal
 PyOpenGL python-opengl
 PyProtocols python-protocols
-PyRRD python-pyrrd
-PyRSS2Gen python-pyrss2gen
 PyRoom pyroom
 PySFML python-sfml
 PyWebDAV python-webdav
-PyX python-pyx
 PyYAML python-yaml
-Pyevolve python-pyevolve
-Pygments python-pygments
 Pyjamas pyjamas-pyjs
-Pylons python-pylons
 Pymacs pymacs
 Pympd pympd
-Pyrex python-pyrex
 Pyste libboost-python1.42-dev
 PythonDaap python-daap
 QuantLib_Python quantlib-python
-Quixote python-quixote
-RBTools python-rbtools
+Quixote python-quixote1
 RSVGSDL python-ggz
-Rabbyt python-rabbyt
-Radicale python-radicale
-Routes python-routes
-SPARQLWrapper python-sparqlwrapper
-SQLAlchemy python-sqlalchemy
-SQLObject python-sqlobject
 SSSDConfig python-sss
-SciTools python-scitools
 ScientificPython python-scientific
-Scrapy python-scrapy
-SetupDocs python-setupdocs
-Shapely python-shapely
 Skype4Py python-skype
 Sonata sonata
 South python-django-south
-Soya python-soya
-Sphinx python-sphinx
-Sponge python-sponge
 SpreadModule python-spread
-Strongwind python-strongwind
 Support mgltools-support
 SymbolType python-peak.util
 Symbolic python-swiginac
-TRML2PDF python-trml2pdf
-Tempita python-tempita
 The_FreeSmartphone_Framework_Daemon fso-frameworkd
 TileCache tilecache
-ToscaWidgets python-toscawidgets
 Trac trac
 TracAccountManager trac-accountmanager
 TracAuthOpenId trac-authopenid
@@ -206,29 +106,8 @@ TracWikiPrintPlugin trac-wikiprint
 TracWikiRename trac-wikirename
 TracWysiwyg trac-wysiwyg
 TracXMLRPC trac-xmlrpc
-Traits python-traits
-TraitsBackendQt python-traitsbackendqt
-TraitsBackendWX python-traitsbackendwx
-TraitsGUI python-traitsgui
-TurboGears python-turbogears
-TurboGears2 python-turbogears2
-TurboJson python-turbojson
-TurboKid python-turbokid
-TurboMail python-turbomail
 Turtle_Art turtleart
-Twisted python-twisted
 TwistedSNMP python-twisted-snmp
-Twisted_Conch python-twisted-conch
-Twisted_Core python-twisted-core
-Twisted_Lore python-twisted-lore
-Twisted_Mail python-twisted-mail
-Twisted_Names python-twisted-names
-Twisted_News python-twisted-news
-Twisted_Runner python-twisted-runner
-Twisted_Web python-twisted-web
-Twisted_Web2 python-twisted-web2
-Twisted_Words python-twisted-words
-UFL python-ufl
 UTpackages mgltools-utpackages
 UTpackages.UTblur mgltools-utpackages
 UTpackages.UTisocontour mgltools-utpackages
@@ -236,35 +115,15 @@ UTpackages.UTmesh mgltools-utpackages
 UTpackages.UTmolderivatives mgltools-utpackages
 UTpackages.UTsdf mgltools-utpackages
 UTpackages.UTvolrend mgltools-utpackages
-VTK python-vtk
 ViewerFramework mgltools-viewerframework
 Vision mgltools-vision
 Volume mgltools-volume
-WebError python-weberror
-WebFlash python-webflash
-WebHelpers python-webhelpers
-WebOb python-webob
-WebTest python-webtest
-Werkzeug python-werkzeug
-Whoosh python-whoosh
-Wicd python-wicd
 WikiTableMacro trac-wikitablemacro
-ZConfig python-zconfig
 ZODB3 python-zodb
-ZSI python-zsi
-ZooKeeper python-zookeeper
-aafigure python-aafigure
 adesklets adesklets
 adns_python python-adns
-adodb python-adodb
-aeidon python-aeidon
 agtl agtl
-albatross python-albatross
-amqplib python-amqplib
-anyjson python-anyjson
 apache_libcloud python-libcloud
-apipkg python-apipkg
-apsw python-apsw
 apt_offline apt-offline
 apt_p2p apt-p2p
 apt_xapian_index apt-xapian-index
@@ -273,25 +132,17 @@ arandr arandr
 archivemail archivemail
 archmage archmage
 arcjobtool arcjobtool
-argparse python-argparse
 arista arista
 astk astk
 atheist atheist
 autokey autokey-common
-avc python-avc
-bcrypt python-bcrypt
 bhtree mgltools-bhtree
 bicyclerepair bicyclerepair
 bitbake bitbake
 bley bley
-bobo python-bobo
-boto python-boto
-bottle python-bottle
 bpython bpython
-bsddb3 python-bsddb3
 buildbot buildbot
 burn burn
-buzhug python-buzhug
 bzr bzr
 bzr_builddeb bzr-builddeb
 bzr_cia cia-clients
@@ -311,78 +162,27 @@ bzr_svn bzr-svn
 bzr_upload bzr-upload
 bzr_xmloutput bzr-xmloutput
 cappuccino cappuccino
-carrot python-carrot
 cfget cfget
-chardet python-chardet
-circuits python-circuits
 cm config-manager
 cnetworkmanager cnetworkmanager
-cogent python-cogent
-configglue python-configglue
-configobj python-configobj
-couchdbkit python-couchdbkit
-coverage python-coverage
-cracklib python-cracklib
-csa python-csa
-cssutils python-cssutils
-cups python-cups
 cvs2svn cvs2svn
-cvxopt python-cvxopt
-cwiid python-cwiid
 cwm python-swap
 cx_bsdiff python-bsdiff
 d_feet d-feet
 dctrl2xml dctrl2xml
 debpartial_mirror debpartial-mirror
-decorator python-decorator
 deluge deluge-common
-demjson python-demjson
-dicoclient python-dicoclient
-dictclient python-dictclient
-dictdlib python-dictdlib
-dingus python-dingus
 dissy dissy
 djagios djagios
 django_ajax_selects django-ajax-selects
-django_app_plugins python-django-app-plugins
-django_auth_ldap python-django-auth-ldap
-django_contact_form python-django-contact-form
-django_countries python-django-countries
-django_dajax python-django-dajax
-django_dajaxice python-django-dajaxice
-django_debug_toolbar python-django-debug-toolbar
-django_genshi python-django-genshi
-django_lint python-django-lint
-django_markupfield python-django-markupfield
-django_nose python-django-nose
 django_openid_auth python-django-auth-openid
-django_picklefield python-django-picklefield
-django_piston python-django-piston
-django_registration python-django-registration
-django_reversion python-django-reversion
-django_rosetta python-django-rosetta
-django_shorturls python-django-shorturls
-django_swordfish python-django-swordfish
-django_tagging python-django-tagging
-django_threaded_multihost python-django-threaded-multihost
-django_tinymce python-django-tinymce
-django_treebeard python-django-treebeard
-dnspython python-dnspython
-docutils python-docutils
-dogtail python-dogtail
 dot2tex dot2tex
-dpkt python-dpkt
-drmaa python-drmaa
 dtrx dtrx
-dulwich python-dulwich
-dumbnet python-dumbnet
 duplicity duplicity
 dynagen dynagen
 eLyXer elyxer
 ears ears
-easyzone python-easyzone
 editmoin editmoin
-elementtidy python-elementtidy
 elisa python-moovida
 elisa_plugin_amazon moovida-plugins-bad
 elisa_plugin_amp moovida-plugins-bad
@@ -416,44 +216,24 @@ elisa_plugin_winremote moovida-plugins-bad
 elisa_plugin_winscreensaver moovida-plugins-good
 elisa_plugin_wmd moovida-plugins-bad
 elisa_plugin_youtube moovida-plugins-ugly
-enum python-enum
 epigrass epigrass
-epydoc python-epydoc
 euca2ools euca2ools
-event python-event
-execnet python-execnet
 explorer bzr-explorer
 fastimport bzr-fastimport
-feedparser python-feedparser
-ferari python-ferari
-fiu python-fiu
 flashbake flashbake
-flickrapi python-flickrapi
 flickrfs flickrfs
-flup python-flup
-fontforge python-fontforge
 fontypython fontypython
-foolscap python-foolscap
-forgetSQL python-forgetsql
-freevo python-freevo
-freshen python-freshen
-fs python-fs
 funkload funkload
 fuse_python python-fuse
 fusil fusil
 fusion_icon fusion-icon
 fuss_launcher fuss-launcher
 galternatives galternatives
-gaphas python-gaphas
 gaphor gaphor
-gasp python-gasp
-gastables python-gastables
 gastablesgui gastables
-gdata python-gdata
 gdevilspie gdevilspie
 gdmodule python-gd
 geomutils mgltools-geomutils
-gevent python-gevent
 geximon geximon
 git_build_package git-buildpackage
 github_cli github-cli
@@ -461,106 +241,53 @@ gitosis gitosis
 giws giws
 gjots2 gjots2
 gle mgltools-gle
-glpk python-glpk
 gmobilemedia gmobilemedia
-gmpy python-gmpy
 gnome_activity_journal gnome-activity-journal
 gnome_app_install gnome-codec-install
 gnuplot_py python-gnuplot
 go2 go2
 googlecl googlecl
-goopy python-goopy
 gozerbot gozerbot
-gpib python-gpib
 gpodder gpodder
-gps python-gps
 gpxviewer gpxviewer
 gracie gracie
 graphviz trac-graphviz
-greenlet python-greenlet
 groundcontrol groundcontrol
 gunicorn gunicorn
 gvb gvb
 gwibber gwibber
 gwrite gwrite
 gyp gyp
-h5py python-h5py
-hachoir_core python-hachoir-core
-hachoir_metadata python-hachoir-metadata
-hachoir_parser python-hachoir-parser
-hachoir_regex python-hachoir-regex
 hellanzb hellanzb
 hgsvn hgsvn
 hgview hgview
-hk_classes python-hk-classes
 hotwire hotwire
-html2text python-html2text
-httplib2 python-httplib2
 ibus_tegaki ibus-tegaki
 icalview trac-icalviewplugin
-import_relative python-import-relative
-importlib python-importlib
 include_server distcc-pump
 indywiki indywiki
-iniparse python-iniparse
-inotifyx python-inotifyx
-instant python-instant
 iotop iotop
-ipaddr python-ipaddr
-ipcalc python-ipcalc
 ipython ipython
-jabberbot python-jabberbot
 jack jack
-jaxml python-jaxml
-joblib python-joblib
-jsonpickle python-jsonpickle
-junitxml python-junitxml
-kaa_base python-kaa-base
-kaa_imlib2 python-kaa-imlib2
-kaa_metadata python-kaa-metadata
-kerberos python-kerberos
 keymapper keymapper
-keyring python-keyring
-kid python-kid
-kinterbasdb python-kinterbasdb
-kiwi python-kiwi
-kjbuckets python-kjbuckets
-lamson python-lamson
 lastfmsubmitd lastfmsubmitd
-launchpadlib python-launchpadlib
-lazr.restfulclient python-lazr.restfulclient
-lazr.uri python-lazr.uri
 lazygal lazygal
-libLAS python-liblas
-libconcord python-libconcord
 libftdi python-ftdi
 libtpclient_py python-tp-client
 libtpproto_py python-tp-netlib
-lightblue python-lightblue
 live_magic live-magic
 llnl_babel python-sidl
 llnl_babel_sidl_sidlx python-sidl
-lockfile python-lockfile
 loggerhead loggerhead
-logilab_astng python-logilab-astng
-logilab_common python-logilab-common
-logilab_constraint python-logilab-constraint
 londonlaw londonlaw
 lottanzb lottanzb
-louis python-louis
 lptools lptools
 lshell lshell
 lucene pylucene
 ludev_t ludevit
-lxml python-lxml
 lybniz lybniz
-mailer python-mailer
-matplotlib python-matplotlib
 mecab_python python-mecab
-mechanize python-mechanize
 megahal megahal
-meld3 python-meld3
-meliae python-meliae
 mercurial mercurial-common
 mglutil mgltools-mglutil
 mic mic2
@@ -568,182 +295,93 @@ mimms mimms
 mingc python-ming
 mini_dinstall mini-dinstall
 miro miro
-mock python-mock
 mod_python libapache2-mod-python
 moin python-moinmoin
-monajat python-monajat
 moosic moosic
-mox python-mox
 mpDris mpdris
-mpmath python-mpmath
-multiprocessing python-multiprocessing
 museek_python_bindings python-museek
 musiclibrarian musiclibrarian
-mutagen python-mutagen
-mygpoclient python-mygpoclient
 namebench namebench
-ncap python-ncap
 neso tryton-neso
-netaddr python-netaddr
-netifaces python-netifaces
 netsnmp_python libsnmp-python
-networkx python-networkx
 nfoview nfoview
 nglister nglister
-nipy python-nipy
-nipype python-nipype
-nose python-nose
-numpy python-numpy
-nwsclient python-nwsclient
-nwsserver python-nwsserver
-oauth python-oauth
 obMenu obmenu
-obexftp python-obexftp
-objgraph python-objgraph
 ocrfeeder ocrfeeder
 offlineimap offlineimap
-okasha python-okasha
 ooolib_python python-ooolib
-openbabel python-openbabel
 openbmap_logger openbmap-logger
 openerp_client openerp-client
 openerp_server openerp-server
 opengltk mgltools-opengltk
 openoffice_python python-openoffice
-openopt python-openopt
-openpyxl python-openpyxl
 openshot openshot
-opster python-opster
 osc osc
 ows ows
 pYsearch python-yahoo
-papyon python-papyon
-paramiko python-paramiko
-pcapy python-pcapy
-pcs python-pcs
 pdfposter pdfposter
 pdfshuffler pdfshuffler
-pefile python-pefile
 pep8 pep8
-pesto python-pesto
-petsc4py python-petsc4py
-pexpect python-pexpect
 photo_uploader photo-uploader
 picard picard
-pisa python-pisa
 pkpgcounter pkpgcounter
-plasTeX python-plastex
-ply python-ply
-polib python-polib
 pondus pondus
-pp python-pp
-pprocess python-pprocess
-prelude python-prelude
 prelude_correlator prelude-correlator
 prelude_notify prelude-notify
-preludedb python-preludedb
-prettytable python-prettytable
 prewikka prewikka
 prioritized_methods python-peak.rules
-protobuf python-protobuf
 prover9_mace4 prover9-mace4
 pssh pssh
-psutil python-psutil
-psycopg2 python-psycopg2
-pudb python-pudb
-py python-py
 pyExcelerator python-excelerator
-pyPdf python-pypdf
 pyPgSQL python-pgsql
 py_Asterisk python-asterisk
 py_pypcap python-pypcap
 py_rrdtool python-rrdtool
 py_sendfile python-sendfile
 pyalsaaudio python-alsaaudio
-pyao python-pyao
-pyasn1 python-pyasn1
 pybackpack pybackpack
 pybridge pybridge
 pybtex pybtex
 pybugz bugz
-pycallgraph python-pycallgraph
-pycha python-pycha
 pychess pychess
 pychm python-chm
 pyclamav python-clamav
-pycountry python-pycountry
 pycrypto python-crypto
-pycryptopp python-pycryptopp
-pycurl python-pycurl
-pydds python-pydds
-pydhcplib python-pydhcplib
 pydicom python-dicom
 pydkim python-dkim
 pydns python-dns
-pydoctor python-pydoctor
 pyelemental python-elemental
 pyenchant python-enchant
-pyepl python-pyepl
 pyfacebook python-facebook
-pyfann python-pyfann
-pyfiglet python-pyfiglet
-pyfits python-pyfits
 pyflakes pyflakes
-pyfribidi python-pyfribidi
-pyftpdlib python-pyftpdlib
-pygame python-pygame
-pygccxml python-pygccxml
 pygdchart python-gdchart2
 pyglf mgltools-pyglf
-pygooglechart python-pygooglechart
 pygopherd pygopherd
 pygpgme python-pyme
 pygpiv python-gpiv
-pygpu python-pygpu
-pygraphviz python-pygraphviz
-pyinotify python-pyinotify
-pykaraoke python-pykaraoke
-pyke python-pyke
-pykickstart python-pykickstart
-pylibacl python-pylibacl
 pyliblo python-liblo
 pyliblzma python-lzma
-pylibmc python-pylibmc
 pylibpcap python-libpcap
 pylibssh2 python-libssh2
 pylint pylint
-pylirc python-pylirc
-pymad python-pymad
-pymetar python-pymetar
 pymilter python-milter
 pymol pymol
-pymssql python-pymssql
 pymucipher python-museek
 pymvpa python-mvpa
 pyneighborhood pyneighborhood
-pynetsnmp python-pynetsnmp
 pynids python-nids
 pynifti python-nifti
 pyofa python-musicdns
 pyogg python-ogg
-pyopencl python-pyopencl
-pyosd python-pyosd
 pyparallel python-parallel
-pyparsing python-pyparsing
-pyproj python-pyproj
 pyqonsole pyqonsole
-pyquery python-pyquery
-pyrad python-pyrad
 pyremctl python-remctl
 pyrit pyrit
 pyrite_publisher pyrite-publisher
 pysane python-imaging-sane
-pyscard python-pyscard
 pyscrabble pyscrabble-common
-pyscript python-pyscript
 pyserial python-serial
 pysnmp python-pysnmp2
-pysnmp_se python-pysnmp-se
 pysparse python-sparse
 pyspi python-at-spi
 pysqlite python-pysqlite1.1
@@ -751,191 +389,81 @@ pystatgrab python-statgrab
 pysubnettree python-subnettree
 pytagsfs pytagsfs
 pytcpwrap python-tcpwrap
-pytest_xdist python-pytest-xdist
 python2_biggles python-pybiggles
-python_Levenshtein python-levenshtein
-python_aalib python-aalib
-python_application python-application
-python_apt python-apt
-python_aspects python-aspects
-python_augeas python-augeas
-python_bibtex python-bibtex
-python_cdb python-cdb
-python_cdd python-cdd
-python_cjson python-cjson
-python_cloudservers python-cloudservers
-python_daemon python-daemon
-python_debian python-debian
-python_distutils_extra python-distutils-extra
 python_djvulibre python-djvu
-python_dmidecode python-dmidecode
-python_dmidecode_dbg python-dmidecode-dbg
 python_e_dbus python-edbus
-python_ecore python-ecore
-python_edje python-edje
-python_elementary python-elementary
-python_evas python-evas
-python_fam python-fam
-python_geoclue python-geoclue
-python_gflags python-gflags
-python_gnutls python-gnutls
 python_graph_core python-pygraph
 python_graph_dot python-pygraph
-python_gtkmvc python-gtkmvc
-python_irclib python-irclib
-python_keyczar python-keyczar
-python_kzorp python-kzorp
-python_ldap python-ldap
 python_libdrizzle python-drizzle
 python_libgearman python-gearman.libgearman
 python_libpisock python-pisock
 python_memcached python-memcache
-python_mhash python-mhash
-python_mpd python-mpd
-python_musicbrainz python-musicbrainz
-python_nmap python-nmap
-python_openid python-openid
-python_oss python-oss
-python_otr python-otr
-python_phoneutils python-phoneutils
-python_pipeline python-pipeline
 python_policyd_spf postfix-policyd-spf-python
-python_prctl python-prctl
-python_ptrace python-ptrace
-python_socksipy python-socksipy
-python_stdnum python-stdnum
-python_twitter python-twitter
-python_xlib python-xlib
-python_xmltv python-xmltv
 python_yapps yapps2
-pytils python-pytils
-pytools python-pytools
 pytrainer pytrainer
-pytyrant python-pytyrant
 pytz python-tz
-pyvorbis python-pyvorbis
-pywapi python-pywapi
-pywbem python-pywbem
 pyweblib python-weblib
-pyxattr python-pyxattr
 pyxdg python-xdg
-pyxine python-pyxine
-pyxmpp python-pyxmpp
 pyzor pyzor
 qbzr qbzr
 qmtest qmtest
-qrencode python-qrencode
 quodlibet exfalso
 rabbitvcs rabbitvcs-core
 radiotray radiotray
-radix python-radix
-rainbow python-rainbow
 rawdog rawdog
-rdflib python-rdflib
 rdiff_backup rdiff-backup
 rebuildd rebuildd
 recaptcha_client python-recaptcha
-redis python-redis
-relational python-relational
 relational_gui relational
 relational_readline relational-cli
-relatorio python-relatorio
 remuco remuco-base
 renpy_module python-renpy
-reportbug python-reportbug
-reportlab python-reportlab
-repoze.tm2 python-repoze.tm2
-repoze.what python-repoze.what
 repoze.what.plugins.sql python-repoze.what-plugins
 repoze.what.plugins.xml python-repoze.what-plugins
 repoze.what_pylons python-repoze.what-plugins
 repoze.what_quickstart python-repoze.what-plugins
-repoze.who python-repoze.who
 repoze.who.plugins.ldap python-repoze.who-plugins
 repoze.who.plugins.openid python-repoze.who-plugins
 repoze.who.plugins.sa python-repoze.who-plugins
 repoze.who_friendlyform python-repoze.who-plugins
 repoze.who_testutil python-repoze.who-plugins
-restkit python-restkit
-rope python-rope
-ropemacs python-ropemacs
 roundup roundup
-rpy python-rpy
-rpy2 python-rpy2
 rst2pdf rst2pdf
 sapgui_package sapgui-package
 scanerrlog scanerrlog
-scapy python-scapy
 scenario mgltools-scenario
-scgi python-scgi
 scikits.learn python-scikits-learn
-scipy python-scipy
-sciscipy python-sciscipy
-sclapp python-sclapp
 screenlets screenlets
 series60_remote series60-remote
 sessioninstaller sessioninstaller
 sff mgltools-sff
-simplegeneric python-simplegeneric
-simplejson python-simplejson
 sixpack sixpack
-slides python-slides
-slimmer python-slimmer
 smart python-smartpm
 smart_notifier smart-notifier
-smbc python-smbc
-smbpasswd python-smbpasswd
-smbus python-smbus
 snimpy snimpy
-soaplib python-soaplib
-sourcecodegen python-sourcecodegen
 spambayes spambayes
 spectacle spectacle
 specto specto
-speechd python-speechd
 speechd_config python-speechd
-sprox python-sprox
 spyder spyder
 sqlalchemy_migrate python-migrate
 startupmanager startupmanager
-stdeb python-stdeb
-stepic python-stepic
 stgit stgit
-stompy python-stompy
-subvertpy python-subvertpy
-suds python-suds
 supervisor supervisor
 supybot supybot
 svnmailer svnmailer
-swiginac python-swiginac
-sympy python-sympy
 symserv mgltools-symserv
 synce_kpm synce-kpm
 synce_sync_engine synce-sync-engine
-tables python-tables
-tagpy python-tagpy
 tailor tailor
 tegaki_pygtk python-tegaki-gtk
 tegaki_python python-tegaki
 tegaki_tools python-tegakitools
 tegaki_train tegaki-train
 tepache tepache
-testrepository python-testrepository
-testresources python-testresources
-testscenarios python-testscenarios
-testtools python-testtools
-textile python-textile
-tg.devtools python-tg.devtools
-tgMochiKit python-tgmochikit
-tgext.admin python-tgext.admin
 tgext.crud python-tgext.admin
-tkSnack python-tksnack
-tornado python-tornado
 tortoisehg tortoisehg
-tracer python-tracer
-transaction python-transaction
 translate_toolkit translate-toolkit
-transmissionrpc python-transmissionrpc
 tritium tritium
 tryton tryton-client
 trytond tryton-server
@@ -987,83 +515,30 @@ trytond_stock_supply tryton-modules-stock-supply
 trytond_stock_supply_day tryton-modules-stock-supply-day
 trytond_timesheet tryton-modules-timesheet
 ttb ttb
-tunepimp python-tunepimp
 tw.forms python-toscawidgets
-twill python-twill
-twyt python-twyt
-uTidylib python-utidylib
 ubuntu_dev_tools ubuntu-dev-tools
 ufw ufw
-unac python-unac
 unattended_upgrades unattended-upgrades
-uncertainties python-uncertainties
-unittest2 python-unittest2
-urlgrabber python-urlgrabber
 urlscan urlscan
-urwid python-urwid
-van.pydeb python-van.pydeb
-vatnumber python-vatnumber
 vboxapi virtualbox-ose
 vcs_load_dirs load-dirs-common
-viper python-viper
 virtaal virtaal
 virtinst virtinst
-virtualenv python-virtualenv
 virtualenvwrapper virtualenvwrapper
-vobject python-vobject
-wadllib python-wadllib
 wammu wammu
 web.py python-webpy
-webunit python-webunit
-whisper python-whisper
 wikipediafs wikipediafs
 winpdb winpdb
-wit python-wit
-wokkel python-wokkel
 wxPython_common python-wxgtk2.6
-wxglade python-wxglade
-xappy python-xappy
-xattr python-xattr
 xgflib xgridfit
-xlrd python-xlrd
-xlwt python-xlwt
 xmldiff xmldiff
 xmms2tray xmms2tray
 xxdiff_scripts xxdiff-scripts
 yagtd yagtd
-yenc python-yenc
 yokadi yokadi
 yum_metadata_parser python-sqlitecachec
-zc.buildout python-zc.buildout
-zc.lockfile python-zc.lockfile
-zdaemon python-zdaemon
 zenmap zenmap
 zeroinstall_injector zeroinstall-injector
 zhone zhone-illume-glue
-zhpy python-zhpy
 zim zim
 zinnia_python python-zinnia
-zope.authentication python-zope.authentication
-zope.browser python-zope.browser
-zope.cachedescriptors python-zope.cachedescriptors
-zope.component python-zope.component
-zope.configuration python-zope.configuration
-zope.contenttype python-zope.contenttype
-zope.copy python-zope.copy
-zope.dottedname python-zope.dottedname
-zope.event python-zope.event
-zope.exceptions python-zope.exceptions
-zope.hookable python-zope.hookable
-zope.i18n python-zope.i18n
-zope.i18nmessageid python-zope.i18nmessageid
-zope.interface python-zope.interface
-zope.location python-zope.location
-zope.proxy python-zope.proxy
-zope.publisher python-zope.publisher
-zope.schema python-zope.schema
-zope.security python-zope.security
-zope.sendmail python-zope.sendmail
-zope.sqlalchemy python-zope.sqlalchemy
-zope.testbrowser python-zope.testbrowser
-zope.testing python-zope.testing
-zope.traversing python-zope.traversing
diff --git a/pydist/generate_fallback_list.py b/pydist/generate_fallback_list.py
index 9775924..0831c90 100755
--- a/pydist/generate_fallback_list.py
+++ b/pydist/generate_fallback_list.py
@@ -24,6 +24,15 @@ import os
 import sys
 from subprocess import Popen, PIPE
 
+skip_sensible_names = True if '--skip-sensible-names' in sys.argv else False
+os.chdir(os.path.dirname(__file__))
+if os.path.isdir('../debpython'):
+    sys.path.append('..')
+else:
+    sys.path.append('/usr/share/python/debpython/')
+from debpython.pydist import sensible_pname
+
+
 if not os.path.isdir('cache'):
     process = Popen('apt-file -s sources.list -c cache update', shell=True)
     process.communicate()
@@ -50,6 +59,8 @@ for line in stdout.splitlines():
                 if i.endswith('.egg-info')][0]
     if egg_name.endswith('.egg'):
         egg_name = egg_name[:-4]
+    if skip_sensible_names and sensible_pname(egg_name) == pname:
+        continue
     if egg_name not in processed:
         processed.add(egg_name)
         result.append("%s %s\n" % (egg_name, pname))
diff --git a/tests/t1/debian/pydist-overrides b/tests/t1/debian/pydist-overrides
index f5800e4..fd6c9d7 100644
--- a/tests/t1/debian/pydist-overrides
+++ b/tests/t1/debian/pydist-overrides
@@ -2,3 +2,4 @@ Mako python-mako (>= 0.2)
 SQLAlchemy python-sqlalchemy (>= 0.6)
 Foo python-foo
 Bar python-bar
+Baz
diff --git a/tests/t1/setup.py b/tests/t1/setup.py
index 99695a1..ee9f359 100644
--- a/tests/t1/setup.py
+++ b/tests/t1/setup.py
@@ -18,5 +18,5 @@ setup(name='Foo',
       packages=find_packages('lib/'),
       package_data = {'foo': ['jquery.js']},
       zip_safe=False,
-      install_requires = ['Mako', 'SQLAlchemy >=0.5'],
+      install_requires = ['Mako', 'SQLAlchemy >=0.5', 'Baz [extras]'],
 )
-- 
GitLab