From: david-sarah Date: Sat, 6 Nov 2010 22:44:04 +0000 (-0800) Subject: misc/build_helpers/show-tool-versions.py: if we can't import pkg_resources, insert... X-Git-Url: https://git.rkrishnan.org/specifications/%5B/%5D%20/%22doc.html/reliability?a=commitdiff_plain;h=f7caef635fbea77db4160d5ece794e3fbc2c4da2;p=tahoe-lafs%2Ftahoe-lafs.git misc/build_helpers/show-tool-versions.py: if we can't import pkg_resources, insert the bundled zetuptoolz egg onto sys.path. --- diff --git a/misc/build_helpers/show-tool-versions.py b/misc/build_helpers/show-tool-versions.py index f7434e47..4b545b51 100644 --- a/misc/build_helpers/show-tool-versions.py +++ b/misc/build_helpers/show-tool-versions.py @@ -2,6 +2,18 @@ import locale, os, subprocess, sys, traceback +added_zetuptoolz_egg = False +try: + import pkg_resources +except ImportError: + import glob + eggz = glob.glob(os.path.join('..', 'setuptools-*.egg')) + if len(eggz) > 0: + egg = os.path.realpath(eggz[0]) + print >>sys.stderr, "Inserting egg on sys.path: %r" % (egg,) + added_zetuptoolz_egg = True + sys.path.insert(0, egg) + def foldlines(s): return s.replace("\n", " ").replace("\r", "") @@ -85,6 +97,10 @@ def print_as_ver(): def print_setuptools_ver(): print + if added_zetuptoolz_egg: + # it would be misleading to report the bundled version of zetuptoolz as the installed version + print "setuptools: using bundled egg" + return try: import pkg_resources out = str(pkg_resources.require("setuptools"))