From: Zooko O'Whielacronx Date: Sun, 1 Aug 2010 16:05:17 +0000 (-0700) Subject: setup: replace hardcoded 'allmydata-tahoe' with allmydata.__appname__ X-Git-Tag: trac-4600~3 X-Git-Url: https://git.rkrishnan.org/vdrive/%22file:/frontends/%22doc.html/%3C?a=commitdiff_plain;h=44edecb36c1cf81b432a456d34e6b50823dda184;p=tahoe-lafs%2Ftahoe-lafs.git setup: replace hardcoded 'allmydata-tahoe' with allmydata.__appname__ --- diff --git a/_auto_deps.py b/_auto_deps.py index d6bf6a4d..c55c9aed 100644 --- a/_auto_deps.py +++ b/_auto_deps.py @@ -107,7 +107,3 @@ def require_auto_deps(): # but it shows a too-old version, then we'll get a # VersionConflict error instead of DistributionNotFound. pass - -def get_package_versions_from_setuptools(): - import pkg_resources - return dict([(p.project_name, (p.version, p.location)) for p in pkg_resources.require('allmydata-tahoe')]) diff --git a/src/allmydata/__init__.py b/src/allmydata/__init__.py index 0b5d6129..97fa15c6 100644 --- a/src/allmydata/__init__.py +++ b/src/allmydata/__init__.py @@ -165,6 +165,10 @@ def get_platform(): else: return platform.platform() +def get_package_versions_from_setuptools(): + import pkg_resources + return dict([(p.project_name, (p.version, p.location)) for p in pkg_resources.require(__appname__)]) + def get_package_versions_and_locations(): # because there are a few dependencies that are outside setuptools's ken # (Python and platform, and sqlite3 if you are on Python >= 2.5), and @@ -192,7 +196,7 @@ def get_package_versions_and_locations(): d1 = { 'pyOpenSSL': (OpenSSL.__version__, os.path.dirname(OpenSSL.__file__)), - 'allmydata-tahoe': (allmydata.__version__, os.path.dirname(allmydata.__file__)), + __appname__: (allmydata.__version__, os.path.dirname(allmydata.__file__)), 'foolscap': (foolscap.api.__version__, os.path.dirname(foolscap.__file__)), 'Nevow': (nevow.__version__, os.path.dirname(nevow.__file__)), 'pycryptopp': (pycryptopp.__version__, os.path.dirname(pycryptopp.__file__)), @@ -210,7 +214,7 @@ def get_package_versions_and_locations(): # But we prefer to get all the dependencies as known by setuptools: import pkg_resources try: - d2 = _auto_deps.get_package_versions_from_setuptools() + d2 = get_package_versions_from_setuptools() except pkg_resources.DistributionNotFound: # See docstring in _auto_deps.require_auto_deps() to explain why it makes sense to ignore this exception. pass @@ -228,7 +232,7 @@ def get_package_locations(): def get_package_versions_string(show_paths=False): vers_and_locs = get_package_versions_and_locations() res = [] - for p in ["allmydata-tahoe", "foolscap", "pycryptopp", "zfec", "Twisted", "Nevow", "zope.interface", "python", "platform"]: + for p in [__appname__, "foolscap", "pycryptopp", "zfec", "Twisted", "Nevow", "zope.interface", "python", "platform"]: (ver, loc) = vers_and_locs.get(p, ('UNKNOWN', 'UNKNOWN')) info = str(p) + ": " + str(ver) if show_paths: diff --git a/src/allmydata/test/test_client.py b/src/allmydata/test/test_client.py index e2e80d89..59a37f98 100644 --- a/src/allmydata/test/test_client.py +++ b/src/allmydata/test/test_client.py @@ -160,7 +160,7 @@ class Basic(testutil.ReallyEqualMixin, unittest.TestCase): self.failUnless("." in str(allmydata.__full_version__), "non-numeric version in '%s'" % allmydata.__version__) all_versions = allmydata.get_package_versions_string() - self.failUnless("allmydata-tahoe" in all_versions) + self.failUnless(allmydata.__appname__ in all_versions) log.msg("tahoe versions: %s" % all_versions) # also test stats stats = c.get_stats() diff --git a/src/allmydata/test/test_runner.py b/src/allmydata/test/test_runner.py index 5ff10ba7..53571a62 100644 --- a/src/allmydata/test/test_runner.py +++ b/src/allmydata/test/test_runner.py @@ -39,10 +39,9 @@ class BinTahoe(common_util.SignalMixin, unittest.TestCase, SkipMixin): out, err, rc_or_sig = res self.failUnlessEqual(rc_or_sig, 0, str((out, err, rc_or_sig))) - # Fail unless the allmydata-tahoe package is *this* version *and* - # was loaded from *this* source directory. + # Fail unless the package is *this* version *and* was loaded from *this* source directory. ad = os.path.dirname(os.path.dirname(os.path.realpath(allmydata.__file__))) - required_ver_and_path = "allmydata-tahoe: %s (%s)" % (allmydata.__version__, ad) + required_ver_and_path = "%s: %s (%s)" % (allmydata.__appname__, allmydata.__version__, ad) self.failUnless(out.startswith(required_ver_and_path), (out, err, rc_or_sig, required_ver_and_path)) d.addCallback(_cb) @@ -60,7 +59,7 @@ class BinTahoe(common_util.SignalMixin, unittest.TestCase, SkipMixin): def _cb(res): out, err, rc_or_sig = res self.failUnlessEqual(rc_or_sig, 0, res) - self.failUnless(out.startswith("allmydata-tahoe:"), res) + self.failUnless(out.startswith(allmydata.__appname__), res) self.failIfIn("DeprecationWarning", out, res) self.failUnlessEqual(err, "", res) d.addCallback(_cb) diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 3351102c..9c285799 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -750,7 +750,7 @@ class SystemTest(SystemTestMixin, unittest.TestCase): d = getPage(self.introweb_url, method="GET", followRedirect=True) def _check(res): try: - self.failUnless("allmydata-tahoe: %s" % str(allmydata.__version__) + self.failUnless("%s: %s" % (allmydata.__appname__, allmydata.__version__) in res) self.failUnless("Announcement Summary: storage: 5, stub_client: 5" in res) self.failUnless("Subscription Summary: storage: 5" in res)