Commit 019c5e9d authored by Shin, Woong's avatar Shin, Woong
Browse files


* Remove unnecessary code from
* Fix version propagation mechanism
Signed-off-by: Shin, Woong's avatarWoong Shin <>
parent c4bc887e
......@@ -22,99 +22,17 @@ module_name = 'pdo'
_REGEX = re.compile(
""", re.VERBOSE)
def git(*args):
"""Helper that invokes git"""
ret =["git"] + list(args), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
ret.git_args = args
return ret
def get_tags(subdir=None, head=None):
"""Get the tags from the current repo
:param subdir: if provided, used as a filter
:param head: if provided, used to limit what we see
:returns: a list of tags
args = ['tag']
if subdir is not None:
if head is not None:
ret = git(*args)
return ret.stdout.decode('utf-8').splitlines()
VERSION = "0.0.1"
def parse_tag(tag):
"""Parse a tag string and return a subdir, semver pair
:param tag: A tag string from git that has subdir-semver format
:returns: A tuple with subdir and semver
match = _REGEX.match(tag)
if match is None:
raise ValueError('%s is not valid SemVer string' % tag)
parts = match.groupdict()
return (parts['subdir'], tag.replace("{}-".format(parts['subdir']), ""))
def index_history(taglist):
"""Get the tag history from the current repo
The result gives you capability of figuring out order of things
If the taglist was based on a single timeline of tags, then it will be
keyed with '.'
:param taglist: A multi-line text blob of multiple tags
:returns: dictionary indexed with subdir names and lists of sorted versions
as values
def cmp_ver(ver1, ver2):
return parse_version(ver1) < parse_version(ver2)
i = defaultdict(list)
for line in taglist:
subdir, ver = parse_tag(line)
r = dict()
for subdir, verlist in i.items():
r[subdir] = sorted(verlist, key=cmp_to_key(cmp_ver))
return r
def get_version(module_name):
def version(module_name):
Retrieve the version
taglist = get_tags(module_name, None)
history = index_history(taglist).get(module_name, None)
if history is not None:
version = history[-1]
# Propagate version to the module
with open('{}/'.format(module_name), 'w+') as f:
f.write('__version__ = "{}"'.format(version))
return version
f.write(f'__version__ = "{VERSION}"')
return VERSION
# Get the long description from the README file
......@@ -141,7 +59,7 @@ setup(
# The project's main homepage.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment