Skip to content

Commit f04c9cf

Browse files
committed
upgrade to versioneer-0.11
1 parent 9a901b6 commit f04c9cf

File tree

4 files changed

+317
-253
lines changed

4 files changed

+317
-253
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# basic metadata
22
include MANIFEST.in LICENSE NEWS README.md versioneer.py
3+
include ecdsa/_version.py

ecdsa/_version.py

Lines changed: 41 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11

22
# This file helps to compute a version number in source trees obtained from
33
# git-archive tarball (such as those provided by githubs download-from-tag
4-
# feature). Distribution tarballs (build by setup.py sdist) and build
4+
# feature). Distribution tarballs (built by setup.py sdist) and build
55
# directories (produced by setup.py build) will contain a much shorter file
66
# that just contains the computed version number.
77

88
# This file is released into the public domain. Generated by
9-
# versioneer-0.9 (https://github.com/warner/python-versioneer)
9+
# versioneer-0.11 (https://github.com/warner/python-versioneer)
1010

1111
# these strings will be replaced by git during git-archive
1212
git_refnames = "$Format:%d$"
1313
git_full = "$Format:%H$"
1414

15+
# these strings are filled in when 'setup.py versioneer' creates _version.py
16+
tag_prefix = "python-ecdsa-"
17+
parentdir_prefix = "ecdsa-"
18+
versionfile_source = "ecdsa/_version.py"
1519

16-
import subprocess
17-
import sys
18-
import errno
19-
20+
import os, sys, re, subprocess, errno
2021

2122
def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False):
2223
assert isinstance(commands, list)
@@ -50,37 +51,46 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False):
5051
return stdout
5152

5253

53-
import sys
54-
import re
55-
import os.path
54+
def versions_from_parentdir(parentdir_prefix, root, verbose=False):
55+
# Source tarballs conventionally unpack into a directory that includes
56+
# both the project name and a version string.
57+
dirname = os.path.basename(root)
58+
if not dirname.startswith(parentdir_prefix):
59+
if verbose:
60+
print("guessing rootdir is '%s', but '%s' doesn't start with prefix '%s'" %
61+
(root, dirname, parentdir_prefix))
62+
return None
63+
return {"version": dirname[len(parentdir_prefix):], "full": ""}
5664

57-
def get_expanded_variables(versionfile_abs):
65+
def git_get_keywords(versionfile_abs):
5866
# the code embedded in _version.py can just fetch the value of these
59-
# variables. When used from setup.py, we don't want to import
60-
# _version.py, so we do it with a regexp instead. This function is not
61-
# used from _version.py.
62-
variables = {}
67+
# keywords. When used from setup.py, we don't want to import _version.py,
68+
# so we do it with a regexp instead. This function is not used from
69+
# _version.py.
70+
keywords = {}
6371
try:
6472
f = open(versionfile_abs,"r")
6573
for line in f.readlines():
6674
if line.strip().startswith("git_refnames ="):
6775
mo = re.search(r'=\s*"(.*)"', line)
6876
if mo:
69-
variables["refnames"] = mo.group(1)
77+
keywords["refnames"] = mo.group(1)
7078
if line.strip().startswith("git_full ="):
7179
mo = re.search(r'=\s*"(.*)"', line)
7280
if mo:
73-
variables["full"] = mo.group(1)
81+
keywords["full"] = mo.group(1)
7482
f.close()
7583
except EnvironmentError:
7684
pass
77-
return variables
85+
return keywords
7886

79-
def versions_from_expanded_variables(variables, tag_prefix, verbose=False):
80-
refnames = variables["refnames"].strip()
87+
def git_versions_from_keywords(keywords, tag_prefix, verbose=False):
88+
if not keywords:
89+
return {} # keyword-finding function failed to find keywords
90+
refnames = keywords["refnames"].strip()
8191
if refnames.startswith("$Format"):
8292
if verbose:
83-
print("variables are unexpanded, not using")
93+
print("keywords are unexpanded, not using")
8494
return {} # unexpanded, so not in an unpacked git-archive tarball
8595
refs = set([r.strip() for r in refnames.strip("()").split(",")])
8696
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
@@ -107,16 +117,17 @@ def versions_from_expanded_variables(variables, tag_prefix, verbose=False):
107117
if verbose:
108118
print("picking %s" % r)
109119
return { "version": r,
110-
"full": variables["full"].strip() }
120+
"full": keywords["full"].strip() }
111121
# no suitable tags, so we use the full revision id
112122
if verbose:
113123
print("no suitable tags, using full revision id")
114-
return { "version": variables["full"].strip(),
115-
"full": variables["full"].strip() }
124+
return { "version": keywords["full"].strip(),
125+
"full": keywords["full"].strip() }
116126

117-
def versions_from_vcs(tag_prefix, root, verbose=False):
127+
128+
def git_versions_from_vcs(tag_prefix, root, verbose=False):
118129
# this runs 'git' from the root of the source tree. This only gets called
119-
# if the git-archive 'subst' variables were *not* expanded, and
130+
# if the git-archive 'subst' keywords were *not* expanded, and
120131
# _version.py hasn't already been rewritten with a short version string,
121132
# meaning we're inside a checked out source tree.
122133

@@ -146,29 +157,14 @@ def versions_from_vcs(tag_prefix, root, verbose=False):
146157
return {"version": tag, "full": full}
147158

148159

149-
def versions_from_parentdir(parentdir_prefix, root, verbose=False):
150-
# Source tarballs conventionally unpack into a directory that includes
151-
# both the project name and a version string.
152-
dirname = os.path.basename(root)
153-
if not dirname.startswith(parentdir_prefix):
154-
if verbose:
155-
print("guessing rootdir is '%s', but '%s' doesn't start with prefix '%s'" %
156-
(root, dirname, parentdir_prefix))
157-
return None
158-
return {"version": dirname[len(parentdir_prefix):], "full": ""}
159-
160-
tag_prefix = "python-ecdsa-"
161-
parentdir_prefix = "ecdsa-"
162-
versionfile_source = "ecdsa/_version.py"
163-
164160
def get_versions(default={"version": "unknown", "full": ""}, verbose=False):
165161
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
166162
# __file__, we can work backwards from there to the root. Some
167163
# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
168-
# case we can only use expanded variables.
164+
# case we can only use expanded keywords.
169165

170-
variables = { "refnames": git_refnames, "full": git_full }
171-
ver = versions_from_expanded_variables(variables, tag_prefix, verbose)
166+
keywords = { "refnames": git_refnames, "full": git_full }
167+
ver = git_versions_from_keywords(keywords, tag_prefix, verbose)
172168
if ver:
173169
return ver
174170

@@ -177,12 +173,11 @@ def get_versions(default={"version": "unknown", "full": ""}, verbose=False):
177173
# versionfile_source is the relative path from the top of the source
178174
# tree (where the .git directory might live) to this file. Invert
179175
# this to find the root from __file__.
180-
for i in range(len(versionfile_source.split("/"))):
176+
for i in range(len(versionfile_source.split(os.sep))):
181177
root = os.path.dirname(root)
182178
except NameError:
183179
return default
184180

185-
return (versions_from_vcs(tag_prefix, root, verbose)
181+
return (git_versions_from_vcs(tag_prefix, root, verbose)
186182
or versions_from_parentdir(parentdir_prefix, root, verbose)
187183
or default)
188-

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
versioneer.versionfile_build = versioneer.versionfile_source
1010
versioneer.tag_prefix = "python-ecdsa-"
1111
versioneer.parentdir_prefix = "ecdsa-"
12+
versioneer.VCS = "git"
1213

1314
commands = versioneer.get_cmdclass().copy()
1415

0 commit comments

Comments
 (0)