From: Zooko O'Whielacronx Date: Fri, 4 Jun 2010 04:41:46 +0000 (-0700) Subject: setup: bundle a copy of darcsver in unzipped egg form in the root of the Tahoe-LAFS... X-Git-Url: https://git.rkrishnan.org/listings/provisioning?a=commitdiff_plain;h=aff500c01c51e6b65932a58d4b95274dd1a76c15;p=tahoe-lafs%2Ftahoe-lafs.git setup: bundle a copy of darcsver in unzipped egg form in the root of the Tahoe-LAFS source tree This is to work-around this Distribute issue: http://bitbucket.org/tarek/distribute/issue/55/revision-control-plugin-automatically-installed-as-a-build-dependency-is-not-present-when-another-build-dependency-is-being --- diff --git a/darcsver-1.5.1-py2.6.egg/EGG-INFO/PKG-INFO b/darcsver-1.5.1-py2.6.egg/EGG-INFO/PKG-INFO new file mode 100644 index 00000000..1cc78cc7 --- /dev/null +++ b/darcsver-1.5.1-py2.6.egg/EGG-INFO/PKG-INFO @@ -0,0 +1,32 @@ +Metadata-Version: 1.0 +Name: darcsver +Version: 1.5.1 +Summary: generate a version number from darcs history +Home-page: http://allmydata.org/trac/darcsver +Author: Zooko O'Whielacronx +Author-email: zooko@zooko.com +License: BSD +Description: UNKNOWN +Keywords: distutils setuptools plugin setup darcs +Platform: UNKNOWN +Classifier: Framework :: Setuptools Plugin +Classifier: Development Status :: 5 - Production/Stable +Classifier: License :: OSI Approved :: BSD License +Classifier: License :: DFSG approved +Classifier: Intended Audience :: Developers +Classifier: Operating System :: Microsoft +Classifier: Operating System :: Microsoft :: Windows +Classifier: Operating System :: Unix +Classifier: Operating System :: POSIX :: Linux +Classifier: Operating System :: POSIX +Classifier: Operating System :: MacOS :: MacOS X +Classifier: Operating System :: Microsoft :: Windows :: Windows NT/2000 +Classifier: Operating System :: OS Independent +Classifier: Natural Language :: English +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.4 +Classifier: Programming Language :: Python :: 2.5 +Classifier: Programming Language :: Python :: 2.6 +Classifier: Topic :: Utilities +Classifier: Topic :: Software Development :: Libraries diff --git a/darcsver-1.5.1-py2.6.egg/EGG-INFO/SOURCES.txt b/darcsver-1.5.1-py2.6.egg/EGG-INFO/SOURCES.txt new file mode 100644 index 00000000..e6b4b543 --- /dev/null +++ b/darcsver-1.5.1-py2.6.egg/EGG-INFO/SOURCES.txt @@ -0,0 +1,16 @@ +README.txt +TODO +setup.cfg +setup.py +darcsver/__init__.py +darcsver/_version.py +darcsver/darcsvermodule.py +darcsver/setuptools_command.py +darcsver.egg-info/PKG-INFO +darcsver.egg-info/SOURCES.txt +darcsver.egg-info/dependency_links.txt +darcsver.egg-info/entry_points.txt +darcsver.egg-info/not-zip-safe +darcsver.egg-info/top_level.txt +scripts/__init__.py +scripts/darcsverscript.py \ No newline at end of file diff --git a/darcsver-1.5.1-py2.6.egg/EGG-INFO/dependency_links.txt b/darcsver-1.5.1-py2.6.egg/EGG-INFO/dependency_links.txt new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/darcsver-1.5.1-py2.6.egg/EGG-INFO/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/darcsver-1.5.1-py2.6.egg/EGG-INFO/entry_points.txt b/darcsver-1.5.1-py2.6.egg/EGG-INFO/entry_points.txt new file mode 100644 index 00000000..23d63651 --- /dev/null +++ b/darcsver-1.5.1-py2.6.egg/EGG-INFO/entry_points.txt @@ -0,0 +1,6 @@ +[console_scripts] +darcsver = scripts.darcsverscript:main + +[distutils.commands] +darcsver = darcsver.setuptools_command:DarcsVer + diff --git a/darcsver-1.5.1-py2.6.egg/EGG-INFO/not-zip-safe b/darcsver-1.5.1-py2.6.egg/EGG-INFO/not-zip-safe new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/darcsver-1.5.1-py2.6.egg/EGG-INFO/not-zip-safe @@ -0,0 +1 @@ + diff --git a/darcsver-1.5.1-py2.6.egg/EGG-INFO/top_level.txt b/darcsver-1.5.1-py2.6.egg/EGG-INFO/top_level.txt new file mode 100644 index 00000000..4eebf095 --- /dev/null +++ b/darcsver-1.5.1-py2.6.egg/EGG-INFO/top_level.txt @@ -0,0 +1,2 @@ +darcsver +scripts diff --git a/darcsver-1.5.1-py2.6.egg/darcsver/__init__.py b/darcsver-1.5.1-py2.6.egg/darcsver/__init__.py new file mode 100644 index 00000000..3421c135 --- /dev/null +++ b/darcsver-1.5.1-py2.6.egg/darcsver/__init__.py @@ -0,0 +1,8 @@ +__version__ = "unknown" +try: + from _version import __version__ +except ImportError: + # We're running in a tree that hasn't run darcsver, and didn't come with a + # _version.py, so we don't know what our version is. This should not happen + # very often. + pass diff --git a/darcsver-1.5.1-py2.6.egg/darcsver/_version.py b/darcsver-1.5.1-py2.6.egg/darcsver/_version.py new file mode 100644 index 00000000..b7045d2c --- /dev/null +++ b/darcsver-1.5.1-py2.6.egg/darcsver/_version.py @@ -0,0 +1,16 @@ + +# This is the version of this tree, as created by setup.py darcsver from the Darcs patch +# information: the main version number is taken from the most recent release +# tag. If some patches have been added since the last release, this will have a +# -NN "build number" suffix, or else a -rNN "revision number" suffix. Please see +# pyutil.version_class for a description of what the different fields mean. + +verstr = "1.5.1" +try: + from pyutil.version_class import Version as pyutil_Version + __version__ = pyutil_Version(verstr) +except (ImportError, ValueError): + # Maybe there is no pyutil installed, or this may be an older version of + # pyutil.version_class which does not support SVN-alike revision numbers. + from distutils.version import LooseVersion as distutils_Version + __version__ = distutils_Version(verstr) diff --git a/darcsver-1.5.1-py2.6.egg/darcsver/darcsvermodule.py b/darcsver-1.5.1-py2.6.egg/darcsver/darcsvermodule.py new file mode 100644 index 00000000..6d1ded03 --- /dev/null +++ b/darcsver-1.5.1-py2.6.egg/darcsver/darcsvermodule.py @@ -0,0 +1,178 @@ +import os, string, sys, re +import xml.dom.minidom +import xml.parsers.expat +from subprocess import Popen, PIPE +from distutils import log + +try: + # If we can import pyutil.version_class then use its regex. + from pyutil import version_class + VERSION_BASE_RE_STR = version_class.VERSION_BASE_RE_STR +except ImportError: + # Else (perhaps a bootstrapping problem),then we'll use this + # regex, which was copied from the pyutil source code on + # 2007-10-30. + VERSION_BASE_RE_STR="(\d+)(\.(\d+)(\.(\d+))?)?((a|b|c)(\d+))?" + +def get_text(nodelist): + rc = "" + for node in nodelist: + if node.nodeType == node.TEXT_NODE: + rc = rc + node.data + return rc + +VERSION_BODY = ''' +# This is the version of this tree, as created by %s from the Darcs patch +# information: the main version number is taken from the most recent release +# tag. If some patches have been added since the last release, this will have a +# -NN "build number" suffix, or else a -rNN "revision number" suffix. Please see +# pyutil.version_class for a description of what the different fields mean. + +verstr = "%s" +try: + from pyutil.version_class import Version as pyutil_Version + __version__ = pyutil_Version(verstr) +except (ImportError, ValueError): + # Maybe there is no pyutil installed, or this may be an older version of + # pyutil.version_class which does not support SVN-alike revision numbers. + from distutils.version import LooseVersion as distutils_Version + __version__ = distutils_Version(verstr) +''' + +def write_version_py(verstr, outfname, EXE_NAME): + f = open(outfname, "wt+") + f.write(VERSION_BODY % (EXE_NAME, verstr,)) + f.close() + +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) + +def update(pkgname, verfilename, revision_number=False, loud=False, abort_if_snapshot=False, EXE_NAME="darcsver"): + """ + @param revision_number If true, count the total number of patches in all + history. If false, count the total number of patches since the most recent + release tag. + + Returns a tuple of (exit code, new version string). + """ + rc = -1 + cmd = ["changes", "--xml-output"] + if not revision_number: + cmd.append("--from-tag=^%s" % (pkgname,)) + + errput = None + try: + p = Popen(["darcs"] + cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True) + except OSError, ose: + if ose.errno == 2 and '~' in os.environ['PATH']: + expanded_path = os.environ['PATH'].replace('~', os.path.expanduser('~')) + msg = ("WARNING: 'darcs' was not found. However '~' was found in your PATH. \n" + "Please note that bugs in python cause it to fail to traverse '~' in \n" + "the user's PATH. Please fix your path, e.g. \nPATH=%s" ) + log.warn(msg % (expanded_path,)) + pass + else: + (output, errput) = p.communicate() + rc = p.returncode + if rc != 0: + try: + p = Popen(["realdarcs.exe"] + cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True) + except OSError, ose: + if ose.errno == 2 and '~' in os.environ['PATH']: + expanded_path = os.environ['PATH'].replace('~', os.path.expanduser('~')) + msg = ("WARNING: 'realdarcs.exe' was not found. However '~' was found in your PATH. \n" + "Please note that bugs in python cause it to fail to traverse '~' in \n" + "the user's PATH. Please fix your path, e.g. \nPATH=%s" ) + log.warn(msg % (expanded_path,)) + pass + else: + (output, errput) = p.communicate() + rc = p.returncode + if rc != 0: + if errput: + log.info("%s: darcs wrote to stderr: '%s'" % (EXE_NAME, errput,)) + if os.path.exists(verfilename): + log.info("%s: Failure from attempt to find version tags with 'darcs changes', and %s already exists, so leaving it alone." % (EXE_NAME, verfilename,)) + return (0, read_version_py(verfilename)) + else: + log.warn("%s: Failure from attempt to find version tags with 'darcs changes', and %s doesn't exist." % (EXE_NAME, verfilename)) + return (rc, None) + + # Filter out bad chars that can cause the XML parser to give up in despair. + # (Thanks to lelit of the tailor project and ndurner and warner for this hack.) + allbadchars = "".join([chr(i) for i in range(0x0a) + [0x0b, 0x0c] + range(0x0e, 0x20) + range(0x7f,0x100)]) + tt = string.maketrans(allbadchars, "-"*len(allbadchars)) + output = output.translate(tt) + + # strip off trailing warning messages that darcs 2.3.1 writes to stdout + endi = output.find("")+len("") + output = output[:endi] + try: + doc = xml.dom.minidom.parseString(output) + except xml.parsers.expat.ExpatError, le: + le.args = tuple(le.args + (output,)) + raise + + changelog = doc.getElementsByTagName("changelog")[0] + patches = changelog.getElementsByTagName("patch") + regexstr = "^TAG %s-(%s)" % (pkgname, VERSION_BASE_RE_STR,) + version_re = re.compile(regexstr) + last_tag = None + count_since_last_patch = 0 + if abort_if_snapshot: + for patch in patches: + name = get_text(patch.getElementsByTagName("name")[0].childNodes) + m = version_re.match(name) + if m: + last_tag = m.group(1) + last_tag = last_tag.encode("utf-8") + break + else: + sys.exit(0) # because abort_if_snapshot + else: + for patch in patches: + name = get_text(patch.getElementsByTagName("name")[0].childNodes) + m = version_re.match(name) + if m: + last_tag = m.group(1) + last_tag = last_tag.encode("utf-8") + break + else: + count_since_last_patch += 1 + + if not last_tag: + if errput: + log.info("%s: darcs wrote to stderr: '%s'" % (EXE_NAME, errput,)) + if os.path.exists(verfilename): + log.warn("%s: I'm unable to find a tag in the darcs history matching \"%s\", so I'm leaving %s alone." % (EXE_NAME, regexstr, verfilename,)) + return (0, read_version_py(verfilename)) + else: + log.warn("%s: I'm unable to find a tag in the darcs history matching \"%s\", and %s doesn't exist." % (EXE_NAME, regexstr, verfilename,)) + return (0, None) + + if revision_number: + if count_since_last_patch: + # this is an interim version + verstr = "%s-r%d" % (last_tag, len(patches)) + else: + # this is a release + verstr = last_tag + else: + if count_since_last_patch: + # this is an interim version + verstr = "%s-%d" % (last_tag, count_since_last_patch) + else: + # this is a release + verstr = last_tag + + write_version_py(verstr, verfilename, EXE_NAME) + log.info("%s: wrote '%s' into %s" % (EXE_NAME, verstr, verfilename,)) + return (0, verstr) diff --git a/darcsver-1.5.1-py2.6.egg/darcsver/setuptools_command.py b/darcsver-1.5.1-py2.6.egg/darcsver/setuptools_command.py new file mode 100644 index 00000000..d556d7b7 --- /dev/null +++ b/darcsver-1.5.1-py2.6.egg/darcsver/setuptools_command.py @@ -0,0 +1,70 @@ +import os + +import setuptools + +from darcsver import darcsvermodule + +class DarcsVer(setuptools.Command): + description = "generate a version number from darcs history" + user_options = [ + ('project-name', None, "name of the project as it appears in the project's release tags (default's the to the distribution name)"), + ('version-file', None, "path to file into which the version number should be written (defaults to the package directory's _version.py)"), + ('count-all-patches', None, "If true, count the total number of patches in all history. If false, count the total number of patches since the most recent release tag."), + ('abort-if-snapshot', None, "If true, the if the current version is a snapshot (not a release tag), then immediately exit the process with exit code 0."), + ] + + def initialize_options(self): + self.project_name = None + self.version_file = None + self.count_all_patches = None + self.abort_if_snapshot = None + + def finalize_options(self): + if self.project_name is None: + self.project_name = self.distribution.get_name() + + if self.version_file is None: + toppackage = '' + # If there is a package with the same name as the project name and + # there is a directory by that name then use that. + packagedir = None + if self.distribution.packages and self.project_name in self.distribution.packages: + toppackage = self.project_name + srcdir = '' + if self.distribution.package_dir: + srcdir = self.distribution.package_dir.get(toppackage) + if not srcdir is None: + srcdir = self.distribution.package_dir.get('', '') + packagedir = os.path.join(srcdir, toppackage) + + if packagedir is None or not os.path.isdir(packagedir): + # Else, if there is a singly-rooted tree of packages, use the + # root of that. + if self.distribution.packages: + for package in self.distribution.packages: + if not toppackage: + toppackage = package + else: + if toppackage.startswith(package+"."): + toppackage = package + else: + if not package.startswith(toppackage+"."): + # Not singly-rooted + toppackage = '' + break + + srcdir = '' + if self.distribution.package_dir: + srcdir = self.distribution.package_dir.get(toppackage) + if srcdir is None: + srcdir = self.distribution.package_dir.get('', '') + packagedir = os.path.join(srcdir, toppackage) + + self.version_file = os.path.join(packagedir, '_version.py') + + if self.abort_if_snapshot is None: + self.abort_if_snapshot=False + + def run(self): + (rc, verstr) = darcsvermodule.update(self.project_name, self.version_file, self.count_all_patches, abort_if_snapshot=self.abort_if_snapshot, EXE_NAME="setup.py darcsver") + self.distribution.metadata.version = verstr diff --git a/darcsver-1.5.1-py2.6.egg/scripts/__init__.py b/darcsver-1.5.1-py2.6.egg/scripts/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/darcsver-1.5.1-py2.6.egg/scripts/darcsverscript.py b/darcsver-1.5.1-py2.6.egg/scripts/darcsverscript.py new file mode 100644 index 00000000..7c54f534 --- /dev/null +++ b/darcsver-1.5.1-py2.6.egg/scripts/darcsverscript.py @@ -0,0 +1,46 @@ +#! /usr/bin/env python + +from optparse import OptionParser +import os, sys + +from darcsver import darcsvermodule, __version__ + +try: + EXE_NAME=os.path.basename(sys.argv[0]) +except: + EXE_NAME="darcsver" + +def main(): + parser = OptionParser(usage="Usage: %prog [options] [pkgname [verfilename]]", + version="%prog " + str(__version__), + prog=EXE_NAME) + parser.add_option("-q", "--quiet", default=False, action="store_true", + help="Be quiet, do the job without any output.") + parser.add_option("--count-all-patches", "--revision-number", default=False, + action="store_true", dest="count_all_patches", + help="By default %s counts the number of patches since the " + "most recent release tag. With this option, it counts " + "all the patches in the repository." % EXE_NAME) + + options, args = parser.parse_args() + + if args: + pkgname = args.pop(0) + else: + pkgname = os.path.basename(os.getcwd()) + if not options.quiet: + print "%s: You didn't pass a pkg-name on the command-line, so I'm going to take the name of the current working directory: \"%s\"" % (EXE_NAME, pkgname,) + + if args: + verfilename = args.pop(0) + else: + verfilename = os.path.join(pkgname, "_version.py") + if not options.quiet: + print "%s: You didn't pass a verfilename on the command-line, so I'm going to build one from the name of the package: \"%s\"" % (EXE_NAME, verfilename,) + + (rc, newverstr) = darcsvermodule.update(pkgname=pkgname, verfilename=verfilename, revision_number=options.count_all_patches, quiet=options.quiet, EXE_NAME=EXE_NAME) + return rc + +if __name__ == "__main__": + rc = main() + sys.exit(rc) diff --git a/darcsver-1.5.1-py2.6.egg/share/doc/python-darcsver/README.txt b/darcsver-1.5.1-py2.6.egg/share/doc/python-darcsver/README.txt new file mode 100644 index 00000000..e2e73812 --- /dev/null +++ b/darcsver-1.5.1-py2.6.egg/share/doc/python-darcsver/README.txt @@ -0,0 +1,91 @@ + +What Does It Do +--------------- + +Create _version.py, based upon the latest darcs release tag. + +If your source tree is coming from darcs (i.e. it is in a darcs repository), +this tool will determine the most recent release tag, count the patches that +have been applied since then, and compute a version number to be written into +_version.py . This version number will be available by doing: + + from your_package_name import __version__ + +Source trees that do not come from darcs (e.g. release tarballs, nightly +tarballs) and are not within a darcs repository should instead, come with a +_version.py that was generated before the tarball was produced. In this case, +this tool will quietly exit without modifying the existing _version.py . + +'release tags' are tags in the source repository that match the following +regexp: + + ^your_package_name-\d+\.\d+(\.\d+)?((a|b|c)(\d+)?)?\w*$ + + +Installation +------------ + +With easy_install: + + easy_install darcsver + +Alternative manual installation: + + tar -zxvf darcsver-X.Y.Z.tar.gz + cd darcsver-X.Y.Z + python setup.py install + +Where X.Y.Z is a version number. + +Alternative to make a specific package use darcsver without installing +darcsver into the system: + + Put "setup_requires=['darcsver']" in the call to setup() in the + package's setup.py file. + + +Usage +----- + +There are two ways to use this: the command-line tool and the +setuptools plugin. + +To use the command-line tool, execute it as: + +darcsver $PACKAGE_NAME $PATH_TO_VERSION_PY + + +To use the setuptools plugin (which enables you to write "./setup.py +darcsver" and which cleverly figures out where the _version.py file +ought to go), you must first package your python module with +`setup.py` and use setuptools. + +The former is well documented in the distutils manual: + + http://docs.python.org/dist/dist.html + +To use setuptools instead of distutils, just edit `setup.py` and +change + + from distutils.core import setup + +to + + from setuptools import setup + + +References +---------- + +How to distribute Python modules with Distutils: + + http://docs.python.org/dist/dist.html + + +Setuptools complete manual: + + http://peak.telecommunity.com/DevCenter/setuptools + + +Thanks to Yannick Gingras for providing the prototype for this +README.txt.