<commit_before>import os
from distutils.core import setup

setup(
    name='python-hglib',
    version='0.1',
    author='<NAME>',
    author_email='<EMAIL>',
    url='http://selenic.com/repo/python-hglib',
    description='Mercurial Python library',
    long_description=open(os.path.join(os.path.dirname(__file__), 'README')).read(),
    license='MIT',
    packages=['hglib'])
<commit_msg>setup: add version number lookup<commit_after>import os, time
from distutils.core import setup

# query Mercurial for version number
version = 'unknown'
if os.path.isdir('.hg'):
    cmd = "hg id -i -t"
    l = os.popen(cmd).read().split()
    while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
        l.pop()
    if len(l) > 1: # tag found
        version = l[-1]
        if l[0].endswith('+'): # propagate the dirty status to the tag
            version += '+'
    elif len(l) == 1: # no tag found
        cmd = 'hg parents --template "{latesttag}+{latesttagdistance}-"'
        version = os.popen(cmd).read() + l[0]
    if version.endswith('+'):
        version += time.strftime('%Y%m%d')
elif os.path.exists('.hg_archival.txt'):
    kw = dict([[t.strip() for t in l.split(':', 1)]
               for l in open('.hg_archival.txt')])
    if 'tag' in kw:
        version =  kw['tag']
    elif 'latesttag' in kw:
        version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw
    else:
        version = kw.get('node', '')[:12]

setup(
    name='python-hglib',
    version=version,
    author='<NAME>',
    author_email='<EMAIL>',
    url='http://selenic.com/repo/python-hglib',
    description='Mercurial Python library',
    long_description=open(os.path.join(os.path.dirname(__file__), 'README')).read(),
    license='MIT',
    packages=['hglib'])

{'fraction_non_alphanumeric': 0.18371961560203504, 'fraction_numerical': 0.008479366873940079, 'mean_word_length': 3.1067285382830625, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1126235', 'n_tokens_mistral': 621, 'n_tokens_neox': 606, 'n_words': 133}