Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'release' into stabilization

  • Loading branch information...
commit ded70e01ec58260ffe574b25a00b9058aa5ae942 2 parents 7152df1 + 4e64952
KWierso KWierso authored
Showing with 57 additions and 15 deletions.
  1. +57 −15 python-lib/cuddlefish/_version.py
72 python-lib/cuddlefish/_version.py
View
@@ -5,7 +5,7 @@
# directories (produced by setup.py build) will contain a much shorter file
# that just contains the computed version number.
-# This file is released into the public domain. Generated by versioneer-0.4
+# This file is released into the public domain. Generated by versioneer-0.6
# (https://github.com/warner/python-versioneer)
# these strings will be replaced by git during git-archive
@@ -80,27 +80,36 @@ def versions_from_expanded_variables(variables, tag_prefix):
return { "version": variables["full"].strip(),
"full": variables["full"].strip() }
-def versions_from_vcs(tag_prefix, verbose=False):
- # this runs 'git' from the directory that contains this file. That either
- # means someone ran a setup.py command (and this code is in
- # versioneer.py, thus the containing directory is the root of the source
- # tree), or someone ran a project-specific entry point (and this code is
- # in _version.py, thus the containing directory is somewhere deeper in
- # the source tree). This only gets called if the git-archive 'subst'
- # variables were *not* expanded, and _version.py hasn't already been
- # rewritten with a short version string, meaning we're inside a checked
- # out source tree.
+def versions_from_vcs(tag_prefix, versionfile_source, verbose=False):
+ # this runs 'git' from the root of the source tree. That either means
+ # someone ran a setup.py command (and this code is in versioneer.py, thus
+ # the containing directory is the root of the source tree), or someone
+ # ran a project-specific entry point (and this code is in _version.py,
+ # thus the containing directory is somewhere deeper in the source tree).
+ # This only gets called if the git-archive 'subst' variables were *not*
+ # expanded, and _version.py hasn't already been rewritten with a short
+ # version string, meaning we're inside a checked out source tree.
try:
- source_dir = os.path.dirname(os.path.abspath(__file__))
+ here = os.path.abspath(__file__)
except NameError:
# some py2exe/bbfreeze/non-CPython implementations don't do __file__
return {} # not always correct
+
+ # versionfile_source is the relative path from the top of the source tree
+ # (where the .git directory might live) to this file. Invert this to find
+ # the root from __file__.
+ root = here
+ for i in range(len(versionfile_source.split("/"))):
+ root = os.path.dirname(root)
+ if not os.path.exists(os.path.join(root, ".git")):
+ return {}
+
GIT = "git"
if sys.platform == "win32":
GIT = "git.cmd"
stdout = run_command([GIT, "describe", "--tags", "--dirty", "--always"],
- cwd=source_dir)
+ cwd=root)
if stdout is None:
return {}
if not stdout.startswith(tag_prefix):
@@ -108,7 +117,7 @@ def versions_from_vcs(tag_prefix, verbose=False):
print "tag '%s' doesn't start with prefix '%s'" % (stdout, tag_prefix)
return {}
tag = stdout[len(tag_prefix):]
- stdout = run_command([GIT, "rev-parse", "HEAD"], cwd=source_dir)
+ stdout = run_command([GIT, "rev-parse", "HEAD"], cwd=root)
if stdout is None:
return {}
full = stdout.strip()
@@ -117,12 +126,45 @@ def versions_from_vcs(tag_prefix, verbose=False):
return {"version": tag, "full": full}
+def versions_from_parentdir(parentdir_prefix, versionfile_source, verbose=False):
+ try:
+ here = os.path.abspath(__file__)
+ # versionfile_source is the relative path from the top of the source
+ # tree (where the .git directory might live) to _version.py, when
+ # this is used by the runtime. Invert this to find the root from
+ # __file__.
+ root = here
+ for i in range(len(versionfile_source.split("/"))):
+ root = os.path.dirname(root)
+ except NameError:
+ # try a couple different things to handle py2exe, bbfreeze, and
+ # non-CPython implementations which don't do __file__. This code
+ # either lives in versioneer.py (used by setup.py) or _version.py
+ # (used by the runtime). In the versioneer.py case, sys.argv[0] will
+ # be setup.py, in the root of the source tree. In the _version.py
+ # case, we have no idea what sys.argv[0] is (some
+ # application-specific runner).
+ root = os.path.dirname(os.path.abspath(sys.argv[0]))
+ # Source tarballs conventionally unpack into a directory that includes
+ # both the project name and a version string.
+ dirname = os.path.basename(root)
+ if not dirname.startswith(parentdir_prefix):
+ if verbose:
+ print "dirname '%s' doesn't start with prefix '%s'" % (dirname, parentdir_prefix)
+ return None
+ return {"version": dirname[len(parentdir_prefix):], "full": ""}
+
tag_prefix = ""
+parentdir_prefix = "addon-sdk-"
+versionfile_source = "python-lib/cuddlefish/_version.py"
+
def get_versions():
variables = { "refnames": git_refnames, "full": git_full }
ver = versions_from_expanded_variables(variables, tag_prefix)
if not ver:
- ver = versions_from_vcs(tag_prefix)
+ ver = versions_from_vcs(tag_prefix, versionfile_source)
+ if not ver:
+ ver = versions_from_parentdir(parentdir_prefix, versionfile_source)
if not ver:
ver = {"version": "unknown", "full": ""}
return ver
Please sign in to comment.
Something went wrong with that request. Please try again.