]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
versioning: include an "appname" in the application version string in the versioning...
authorZooko O'Whielacronx <zooko@zooko.com>
Thu, 12 Feb 2009 00:18:16 +0000 (17:18 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Thu, 12 Feb 2009 00:18:16 +0000 (17:18 -0700)
It is currently hardcoded in setup.py to be 'allmydata-tahoe'.  Ticket #556 is to make it configurable by a runtime command-line argument to setup.py: "--appname=foo", but I suddenly wondered if we really wanted that and at the same time realized that we don't need that for tahoe-1.3.0 release, so this patch just hardcodes it in setup.py.
setup.py inspects a file named 'src/allmydata/_appname.py' and assert that it contains the string "__appname__ = 'allmydata-tahoe'", and creates it if it isn't already present.  src/allmydata/__init__.py import _appname and reads __appname__ from it.  The rest of the Python code imports allmydata and inspects "allmydata.__appname__", although actually every use it uses "allmydata.__full_version__" instead, where "allmydata.__full_version__" is created in src/allmydata/__init__.py to be:

__full_version__ = __appname + '-' + str(__version__).

All the code that emits an "application version string" when describing what version of a protocol it supports (introducer server, storage server, upload helper), or when describing itself in general (introducer client), usese allmydata.__full_version__.

This fixes ticket #556 at least well enough for tahoe-1.3.0 release.

setup.py
src/allmydata/__init__.py
src/allmydata/client.py
src/allmydata/immutable/offloaded.py
src/allmydata/introducer/server.py
src/allmydata/scripts/common_http.py
src/allmydata/storage.py
src/allmydata/test/test_client.py
src/allmydata/test/test_upload.py

index 7183b684f62c71e3ff654370869fb18ef57eecec..acfd10467e48b5741a5c87afb5467813765bb455 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -302,7 +302,20 @@ class MySdist(sdist.sdist):
 # _auto_deps.install_requires list, which is used in the call to setup() below.
 from _auto_deps import install_requires
 
-setup(name='allmydata-tahoe',
+APPNAME='allmydata-tahoe'
+APPNAMEFILE = os.path.join('src', 'allmydata', '_appname.py')
+APPNAMEFILESTR = "__appname__ = '%s'" % (APPNAME,)
+try:
+    curappnamefilestr = open(APPNAMEFILE, 'rU').read()
+except EnvironmentError:
+    # No file, or unreadable or something, okay then let's try to write one.
+    open(APPNAMEFILE, "w").write(APPNAMEFILESTR)
+else:
+    if curappnamefilestr.strip() != APPNAMEFILESTR:
+        print "Error -- this setup.py file is configured with the 'application name' to be '%s', but there is already a file in place in '%s' which contains the contents '%s'.  If the file is wrong, please remove it and setup.py will regenerate it and write '%s' into it." % (APPNAME, APPNAMEFILE, curappnamefilestr, APPNAMEFILESTR)
+        sys.exit(-1)
+
+setup(name=APPNAME,
       description='secure, decentralized, fault-tolerant filesystem',
       long_description=LONG_DESCRIPTION,
       author='the allmydata.org Tahoe project',
index a442d8426c43e49903e2543121dc3f3b937d7459..dacb8c6a19d827ddfdfd916bb76c74909e46bcf4 100644 (file)
@@ -15,6 +15,18 @@ except ImportError:
     # not happen very often.
     pass
 
+__appname__ = "unknown"
+try:
+    from _appname import __appname__
+except ImportError:
+    # We're running in a tree that hasn't run "./setup.py".  This shouldn't happen.
+    pass
+
+# __full_version__ is the one that you ought to use when identifying yourself in the
+# "application" part of the Tahoe versioning scheme:
+# http://allmydata.org/trac/tahoe/wiki/Versioning
+__full_version__ = __appname__ + '-' + str(__version__)
+
 hush_pyflakes = __version__
 del hush_pyflakes
 
index 10369bdf20bfdf9778c79c07cd008f9d0c4ddef3..73849c988e4fc4baf7e58167af16b75fe6b50418 100644 (file)
@@ -115,7 +115,7 @@ class Client(node.Node, pollmixin.PollMixin):
         self.introducer_furl = self.get_config("client", "introducer.furl")
         ic = IntroducerClient(self.tub, self.introducer_furl,
                               self.nickname,
-                              str(allmydata.__version__),
+                              str(allmydata.__full_version__),
                               str(self.OLDEST_SUPPORTED_VERSION))
         self.introducer_client = ic
         # hold off on starting the IntroducerClient until our tub has been
index 775b71e6540a073c5e38f0a56448a806c278c55a..60a40624c96cd438d702715a644e0921783ed177 100644 (file)
@@ -5,7 +5,7 @@ from twisted.application import service
 from twisted.internet import defer
 from foolscap import Referenceable, DeadReferenceError
 from foolscap.eventual import eventually
-import allmydata
+import allmydata # for __full_version__
 from allmydata import interfaces, storage, uri
 from allmydata.immutable import upload
 from allmydata.immutable.layout import ReadBucketProxy
@@ -132,7 +132,7 @@ class CHKUploadHelper(Referenceable, upload.CHKUploader):
     implements(interfaces.RICHKUploadHelper)
     VERSION = { "http://allmydata.org/tahoe/protocols/helper/chk-upload/v1" :
                  { },
-                "application-version": str(allmydata.__version__),
+                "application-version": str(allmydata.__full_version__),
                 }
 
     def __init__(self, storage_index, helper,
@@ -492,7 +492,7 @@ class Helper(Referenceable, service.MultiService):
     name = "helper"
     VERSION = { "http://allmydata.org/tahoe/protocols/helper/v1" :
                  { },
-                "application-version": str(allmydata.__version__),
+                "application-version": str(allmydata.__full_version__),
                 }
     chk_upload_helper_class = CHKUploadHelper
     MAX_UPLOAD_STATUSES = 10
index 3005b54d00662985973c5f6b40da130c197302b7..5e519533d7b68d035ade4be23451918220e66797 100644 (file)
@@ -49,7 +49,7 @@ class IntroducerService(service.MultiService, Referenceable):
     name = "introducer"
     VERSION = { "http://allmydata.org/tahoe/protocols/introducer/v1":
                  { },
-                "application-version": str(allmydata.__version__),
+                "application-version": str(allmydata.__full_version__),
                 }
 
     def __init__(self, basedir="."):
index c654927b848dc5c4be35f0fb1a199a2334e02282..0c7680e2a464ac0addaf71aba9557ccee5c5c4d8 100644 (file)
@@ -1,7 +1,7 @@
 
 from cStringIO import StringIO
 import urlparse, httplib
-import allmydata # for __version__
+import allmydata # for __full_version__
 
 # copied from twisted/web/client.py
 def parse_url(url, defaultPort=None):
@@ -44,7 +44,7 @@ def do_http(method, url, body=""):
         raise ValueError("unknown scheme '%s', need http or https" % scheme)
     c.putrequest(method, path)
     c.putheader("Hostname", host)
-    c.putheader("User-Agent", "tahoe_cli/%s" % allmydata.__version__)
+    c.putheader("User-Agent", "tahoe_cli/%s" % allmydata.__full_version__)
     c.putheader("Connection", "close")
 
     old = body.tell()
index e2fbb4f82a2d6eacdd65ee6c95d53a2fc7623429..ac6de53c76282235a1b829b712c0fa923751f861 100644 (file)
@@ -8,7 +8,7 @@ from allmydata.interfaces import RIStorageServer, RIBucketWriter, \
      RIBucketReader, BadWriteEnablerError, IStatsProducer
 from allmydata.util import base32, fileutil, idlib, log, time_format
 from allmydata.util.assertutil import precondition
-import allmydata # for __version__
+import allmydata # for __full_version__
 
 class DataTooLargeError(Exception):
     pass
@@ -968,7 +968,7 @@ class StorageServer(service.MultiService, Referenceable):
                       "tolerates-immutable-read-overrun": True,
                       "delete-mutable-shares-with-zero-length-writev": True,
                       },
-                    "application-version": str(allmydata.__version__),
+                    "application-version": str(allmydata.__full_version__),
                     }
         return version
 
index 099c40a7e37ae6326a19bc51c3ca1488e5953b98..f878101ab37ae241215d4452afdd86fa4991cd08 100644 (file)
@@ -174,12 +174,12 @@ class Basic(unittest.TestCase):
         ss = c.getServiceNamed("storage")
         verdict = ss.remote_get_version()
         self.failUnlessEqual(verdict["application-version"],
-                             str(allmydata.__version__))
+                             str(allmydata.__full_version__))
         self.failIfEqual(str(allmydata.__version__), "unknown")
-        self.failUnless("." in str(allmydata.__version__),
+        self.failUnless("." in str(allmydata.__full_version__),
                         "non-numeric version in '%s'" % allmydata.__version__)
         all_versions = allmydata.get_package_versions_string()
-        self.failUnless("allmydata" in all_versions)
+        self.failUnless("allmydata-tahoe" in all_versions)
         log.msg("tahoe versions: %s" % all_versions)
         # also test stats
         stats = c.get_stats()
index 42c5610115f26ccd604cf4cca866764b1171610a..8ed01e2c7603f2623b7f275d732d018523fde0fb 100644 (file)
@@ -7,7 +7,7 @@ from twisted.python import log
 from twisted.internet import defer
 from foolscap import eventual
 
-import allmydata
+import allmydata # for __full_version__
 from allmydata import uri, monitor
 from allmydata.immutable import upload
 from allmydata.interfaces import IFileURI, FileTooLargeError, NotEnoughSharesError
@@ -84,12 +84,12 @@ class FakeStorageServer:
         self.queries = 0
         self.version = { "http://allmydata.org/tahoe/protocols/storage/v1" :
                          { "maximum-immutable-share-size": 2**32 },
-                         "application-version": str(allmydata.__version__),
+                         "application-version": str(allmydata.__full_version__),
                          }
         if mode == "small":
             self.version = { "http://allmydata.org/tahoe/protocols/storage/v1" :
                              { "maximum-immutable-share-size": 10 },
-                             "application-version": str(allmydata.__version__),
+                             "application-version": str(allmydata.__full_version__),
                              }