[tahoe-lafs-trac-stream] [Tahoe-LAFS] #2242: exception from parsing requirements

Tahoe-LAFS trac at tahoe-lafs.org
Tue Mar 17 16:50:02 UTC 2015


#2242: exception from parsing requirements
---------------------------+-----------------------------------------------
     Reporter:  zooko      |      Owner:
         Type:  defect     |     Status:  new
     Priority:  normal     |  Milestone:  soon
    Component:  packaging  |    Version:  1.10.0
   Resolution:             |   Keywords:  setuptools pkg_resources coverage
Launchpad Bug:             |
---------------------------+-----------------------------------------------

Comment (by zooko):

 Here is a patch that is intended to fix this by checking whether
 `__requires__` is a string or a list, and if it is a string then treat it
 as a list of one element:

 {{{
 diff --git a/setuptools-0.6c16dev5.egg/pkg_resources.py
 b/setuptools-0.6c16dev5.egg/pkg_resources.py
 index a94d89f..a026b1b 100644
 --- a/setuptools-0.6c16dev5.egg/pkg_resources.py
 +++ b/setuptools-0.6c16dev5.egg/pkg_resources.py
 @@ -529,14 +529,20 @@ class WorkingSet(object):
          # If we have a __requires__ then we can already tell if this
          # dist is unsatisfactory, in which case we won't add it.
          if __requires__ is not None:
 -            for thisreqstr in __requires__:
 +            assert isinstance(__requires__, (basestring, list)),
 repr(__requires__)
 +            if isinstance(__requires__, basestring):
 +                array_of__requires__ = [__requires__]
 +            else:
 +                array_of__requires__ = __requires__
 +
 +            for thisreqstr in array_of__requires__:
                  try:
                      for thisreq in parse_requirements(thisreqstr):
                          if thisreq.key == dist.key:
                              if dist not in thisreq:
                                  return
                  except ValueError, e:
 -                    e.args = tuple(e.args + ({'thisreqstr':
 thisreqstr},))
 +                    e.args = tuple(e.args + ({'thisreqstr': thisreqstr,
 '__requires__': __requires__},))
                      raise

          self.by_key[dist.key] = dist
 }}}

 I tested this patch manually, and it changed the error shown in comment:4
 to this result, which I think means it worked:

 {{{
 pkg_resources.require('Twisted') =>  [Twisted 15.0.0
 (/usr/local/lib/python2.7/dist-packages/Twisted-15.0.0-py2.7-linux-
 x86_64.egg), zope.interface 4.0.5 (/usr/lib/python2.7/dist-packages)]
 import Twisted;print Twisted =>
 Traceback (most recent call last):
   File "/usr/local/bin/verinfo", line 9, in <module>
     load_entry_point('pyutil==unknown', 'console_scripts', 'verinfo')()
   File "/usr/local/lib/python2.7/dist-packages/pyutil-unknown-
 py2.7.egg/pyutil/scripts/verinfo.py", line 22, in main
     x = __import__(PACKNAME)
 ImportError: No module named Twisted
 }}}

--
Ticket URL: <https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2242#comment:6>
Tahoe-LAFS <https://Tahoe-LAFS.org>
secure decentralized storage


More information about the tahoe-lafs-trac-stream mailing list