From 4441e1fcd6c33c15f09a97b9dc76401613ebfdde Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Mon, 17 Aug 2009 18:00:57 -0700 Subject: [PATCH] setup.py: read _version.py and pass to setup(version=), so more commands work like "setup.py --version" and "setup.py --fullname" --- setup.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 ) -- 2.45.2