From: Zooko O'Whielacronx Date: Fri, 18 Apr 2008 19:17:22 +0000 (-0700) Subject: setup: don't try __import__(name) in _auto_deps.py X-Git-Tag: allmydata-tahoe-1.1.0~217 X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/class-simplejson.JSONDecoder-index.html?a=commitdiff_plain;h=dbde3d5632d64e646dc662784f4dab616c91af53;p=tahoe-lafs%2Ftahoe-lafs.git setup: don't try __import__(name) in _auto_deps.py This happens to work, because all of our "distribution" (i.e. distributable packaged Python code) names to coincide with all of their "package" (i.e. a directory with a __init__.py in it, which is "import"-able) names, except, I think for Twisted on Brian's debian sid system. But there's no reason why it should always work, and the only reason for that __import__() was to give us an explicit error message indicating missing requirements in the case that pkg_resources isn't importable or that the requirements don't have correct .egg-info metadata. So, by removing this stanza we may allow certain places to get a more ad-hoc failure message, i.e. an ImportError from somewhere, instead of an ImportError from _auto_deps.py, but that's okay. Note that dependencies which do not have their .egg-info metadata with them are increasingly rare, since Python 2.5 distutils creates the .egg-info file by default, and Linux distributions have stopped their former practice of actively deleting the .egg-info files. --- diff --git a/_auto_deps.py b/_auto_deps.py index c92f5cc1..78b040bc 100644 --- a/_auto_deps.py +++ b/_auto_deps.py @@ -26,20 +26,14 @@ def require_auto_deps(): pkg_resources.require(requirement) except pkg_resources.DistributionNotFound: # there is no .egg-info present for this requirement, which - # either means that it isn't installed, or it is installed in - # a way that pkg_resources can't find it (but regular python - # might). The __import__ below will pass the second case, - # which is good enough for us. There are several - # distributions which provide our dependencies just fine, but - # they don't ship .egg-info files. Note that if there *is* an - # .egg-info file, but it indicates an older version, then - # we'll get a VersionConflict error instead of - # DistributionNotFound. + # either means that it isn't installed, or it is installed in a + # way that pkg_resources can't find it (but regular python + # might). There are several older Linux distributions which + # provide our dependencies just fine, but they don't ship + # .egg-info files. Note that if there *is* an .egg-info file, + # but it shows a too-old version, then we'll get a + # VersionConflict error instead of DistributionNotFound. pass - for requirement in install_requires: - reqparts = requirement.split() - name = reqparts[0] - __import__(name) if __name__ == "__main__": require_auto_deps()