1-
21# This file helps to compute a version number in source trees obtained from
32# git-archive tarball (such as those provided by githubs download-from-tag
43# feature). Distribution tarballs (build by setup.py sdist) and build
87# This file is released into the public domain. Generated by
98# versioneer-0.10 (https://github.com/warner/python-versioneer)
109
10+ import errno
11+ import os .path
12+ import re
13+ import subprocess
14+ import sys
15+
1116# these strings will be replaced by git during git-archive
1217git_refnames = "$Format:%d$"
1318git_full = "$Format:%H$"
1419
1520
16- import subprocess
17- import sys
18- import errno
19-
20-
2121def run_command (commands , args , cwd = None , verbose = False , hide_stderr = False ):
2222 assert isinstance (commands , list )
2323 p = None
@@ -50,18 +50,14 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False):
5050 return stdout
5151
5252
53- import sys
54- import re
55- import os .path
56-
5753def get_expanded_variables (versionfile_abs ):
5854 # the code embedded in _version.py can just fetch the value of these
5955 # variables. When used from setup.py, we don't want to import
6056 # _version.py, so we do it with a regexp instead. This function is not
6157 # used from _version.py.
6258 variables = {}
6359 try :
64- f = open (versionfile_abs ,"r" )
60+ f = open (versionfile_abs , "r" )
6561 for line in f .readlines ():
6662 if line .strip ().startswith ("git_refnames =" ):
6763 mo = re .search (r'=\s*"(.*)"' , line )
@@ -76,12 +72,13 @@ def get_expanded_variables(versionfile_abs):
7672 pass
7773 return variables
7874
75+
7976def versions_from_expanded_variables (variables , tag_prefix , verbose = False ):
8077 refnames = variables ["refnames" ].strip ()
8178 if refnames .startswith ("$Format" ):
8279 if verbose :
8380 print ("variables are unexpanded, not using" )
84- return {} # unexpanded, so not in an unpacked git-archive tarball
81+ return {} # unexpanded, so not in an unpacked git-archive tarball
8582 refs = set ([r .strip () for r in refnames .strip ("()" ).split ("," )])
8683 # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
8784 # just "foo-1.0". If we see a "tag: " prefix, prefer those.
@@ -97,7 +94,7 @@ def versions_from_expanded_variables(variables, tag_prefix, verbose=False):
9794 # "stabilization", as well as "HEAD" and "master".
9895 tags = set ([r for r in refs if re .search (r'\d' , r )])
9996 if verbose :
100- print ("discarding '%s', no digits" % "," .join (refs - tags ))
97+ print ("discarding '%s', no digits" % "," .join (refs - tags ))
10198 if verbose :
10299 print ("likely tags: %s" % "," .join (sorted (tags )))
103100 for ref in sorted (tags ):
@@ -106,13 +103,14 @@ def versions_from_expanded_variables(variables, tag_prefix, verbose=False):
106103 r = ref [len (tag_prefix ):]
107104 if verbose :
108105 print ("picking %s" % r )
109- return { "version" : r ,
110- "full" : variables ["full" ].strip () }
106+ return {"version" : r ,
107+ "full" : variables ["full" ].strip ()}
111108 # no suitable tags, so we use the full revision id
112109 if verbose :
113110 print ("no suitable tags, using full revision id" )
114- return { "version" : variables ["full" ].strip (),
115- "full" : variables ["full" ].strip () }
111+ return {"version" : variables ["full" ].strip (),
112+ "full" : variables ["full" ].strip ()}
113+
116114
117115def versions_from_vcs (tag_prefix , root , verbose = False ):
118116 # this runs 'git' from the root of the source tree. This only gets called
@@ -157,17 +155,19 @@ def versions_from_parentdir(parentdir_prefix, root, verbose=False):
157155 return None
158156 return {"version" : dirname [len (parentdir_prefix ):], "full" : "" }
159157
158+
160159tag_prefix = "v"
161160parentdir_prefix = "httpsig-"
162161versionfile_source = "httpsig/_version.py"
163162
163+
164164def get_versions (default = {"version" : "unknown" , "full" : "" }, verbose = False ):
165165 # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
166166 # __file__, we can work backwards from there to the root. Some
167167 # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
168168 # case we can only use expanded variables.
169169
170- variables = { "refnames" : git_refnames , "full" : git_full }
170+ variables = {"refnames" : git_refnames , "full" : git_full }
171171 ver = versions_from_expanded_variables (variables , tag_prefix , verbose )
172172 if ver :
173173 return ver
@@ -185,4 +185,3 @@ def get_versions(default={"version": "unknown", "full": ""}, verbose=False):
185185 return (versions_from_vcs (tag_prefix , root , verbose )
186186 or versions_from_parentdir (parentdir_prefix , root , verbose )
187187 or default )
188-
0 commit comments