How to use the pyscaffold.contrib.setuptools_scm.setuptools_scm.version.meta function in PyScaffold

To help you get started, we’ve selected a few PyScaffold examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyscaffold / pyscaffold / pyscaffold / contrib / setuptools_scm / setuptools_scm / hg.py View on Github external
def parse(root):
    if not has_command('hg'):
        return
    l = do('hg id -i -t', root).split()
    if not l:
        return
    node = l.pop(0)
    tags = tags_to_versions(l)
    # filter tip in degraded mode on old setuptools
    tags = [x for x in tags if x != 'tip']
    dirty = node[-1] == '+'
    if tags:
        return meta(tags[0], dirty=dirty)

    if node.strip('+') == '0'*12:
        trace('initial node', root)
        return meta('0.0', dirty=dirty)

    # the newline is needed for merge stae, see issue 72
    cmd = 'hg parents --template "{latesttag} {latesttagdistance}\n"'
    out = do(cmd, root)
    try:
        # in merge state we assume parent 1 is fine
        tags, dist = out.splitlines()[0].split()
        # pick latest tag from tag list
        tag = tags.split(':')[-1]
        if tag == 'null':
            tag = '0.0'
            dist = int(dist) + 1
github pyscaffold / pyscaffold / pyscaffold / contrib / setuptools_scm / setuptools_scm / hg.py View on Github external
def _hg_tagdist_normalize_tagcommit(root, tag, dist, node):
    dirty = node.endswith('+')
    node = 'h' + node.strip('+')
    revset = ("(branch(.) and tag({tag!r})::. and file('re:^(?!\.hgtags).*$')"
              " - tag({tag!r}))").format(tag=tag)
    if tag != '0.0':
        commits = do(['hg', 'log', '-r', revset, '--template', '{node|short}'],
                     root)
    else:
        commits = True
    trace('normalize', locals())
    if commits or dirty:
        return meta(tag, distance=dist, node=node, dirty=dirty)
    else:
        return meta(tag)
github pyscaffold / pyscaffold / pyscaffold / contrib / setuptools_scm / setuptools_scm / hg.py View on Github external
def _hg_tagdist_normalize_tagcommit(root, tag, dist, node):
    dirty = node.endswith('+')
    node = 'h' + node.strip('+')
    revset = ("(branch(.) and tag({tag!r})::. and file('re:^(?!\.hgtags).*$')"
              " - tag({tag!r}))").format(tag=tag)
    if tag != '0.0':
        commits = do(['hg', 'log', '-r', revset, '--template', '{node|short}'],
                     root)
    else:
        commits = True
    trace('normalize', locals())
    if commits or dirty:
        return meta(tag, distance=dist, node=node, dirty=dirty)
    else:
        return meta(tag)
github pyscaffold / pyscaffold / pyscaffold / contrib / setuptools_scm / setuptools_scm / hg.py View on Github external
def archival_to_version(data):
    trace('data', data)
    node = data.get('node', '')[:12]
    if node:
        node = 'h' + node
    if 'tag' in data:
        return meta(data['tag'])
    elif 'latesttag' in data:
        return meta(data['latesttag'],
                    distance=data['latesttagdistance'],
                    node=node)
    else:
        return meta('0.0', node=node)
github pyscaffold / pyscaffold / pyscaffold / contrib / setuptools_scm / setuptools_scm / hg.py View on Github external
def archival_to_version(data):
    trace('data', data)
    node = data.get('node', '')[:12]
    if node:
        node = 'h' + node
    if 'tag' in data:
        return meta(data['tag'])
    elif 'latesttag' in data:
        return meta(data['latesttag'],
                    distance=data['latesttagdistance'],
                    node=node)
    else:
        return meta('0.0', node=node)
github pyscaffold / pyscaffold / pyscaffold / contrib / setuptools_scm / setuptools_scm / hg.py View on Github external
def archival_to_version(data):
    trace('data', data)
    node = data.get('node', '')[:12]
    if node:
        node = 'h' + node
    if 'tag' in data:
        return meta(data['tag'])
    elif 'latesttag' in data:
        return meta(data['latesttag'],
                    distance=data['latesttagdistance'],
                    node=node)
    else:
        return meta('0.0', node=node)