From: Brian Warner Date: Tue, 18 Aug 2009 01:00:57 +0000 (-0700) Subject: setup.py: read _version.py and pass to setup(version=), so more commands work X-Git-Tag: trac-4100~48 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/webapi.txt?a=commitdiff_plain;h=4441e1fcd6c33c15f09a97b9dc76401613ebfdde;p=tahoe-lafs%2Ftahoe-lafs.git setup.py: read _version.py and pass to setup(version=), so more commands work like "setup.py --version" and "setup.py --fullname" --- diff --git a/setup.py b/setup.py index 6d959d3c..0ea3fc10 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ # # See the docs/about.html file for licensing information. -import os, shutil, stat, subprocess, sys, zipfile +import os, shutil, stat, subprocess, sys, zipfile, re ##### sys.path management @@ -22,6 +22,21 @@ def pylibdir(prefixdir): basedir = os.path.dirname(os.path.abspath(__file__)) supportlib = pylibdir(os.path.join(basedir, "support")) +# locate our version number + +def read_version_py(infname): + try: + verstrline = open(infname, "rt").read() + except EnvironmentError: + return None + else: + VSRE = r"^verstr = ['\"]([^'\"]*)['\"]" + mo = re.search(VSRE, verstrline, re.M) + if mo: + return mo.group(1) + +version = read_version_py("src/allmydata/_version.py") + try: from ez_setup import use_setuptools except ImportError: @@ -337,6 +352,10 @@ else: 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_args = {} +if version: + setup_args["version"] = version + setup(name=APPNAME, description='secure, decentralized, fault-tolerant filesystem', long_description=LONG_DESCRIPTION, @@ -361,4 +380,5 @@ setup(name=APPNAME, setup_requires=setup_requires, entry_points = { 'console_scripts': [ 'tahoe = allmydata.scripts.runner:run' ] }, zip_safe=False, # We prefer unzipped for easier access. + **setup_args )