<commit_before>from setuptools import setup


name = 'tugs'
description = (
    'GR(1) synthesizer using Cython.')
url = 'https://github.com/johnyf/{name}'.format(name=name)
README = 'README.md'
VERSION_FILE = '{name}/_version.py'.format(name=name)
MAJOR = 0
MINOR = 1
MICRO = 1
version = '{major}.{minor}.{micro}'.format(
    major=MAJOR, minor=MINOR, micro=MICRO)
s = (
    '# This file was generated from setup.py\n'
    "version = '{version}'\n").format(version=version)
install_requires = [
    'dd >= 0.1.3',
    'omega >= 0.0.3']
tests_require = [
    'nose >= 1.3.4']


def run_setup():
    with open(VERSION_FILE, 'w') as f:
        f.write(s)
    setup(
        name=name,
        version=version,
        description=description,
        long_description=open(README).read(),
        author='<NAME>',
        author_email='<EMAIL>',<commit_msg>REL: retrieve commit hash from git and recognize version tags<commit_after>from setuptools import setup
# inline
# import git


name = 'tugs'
description = (
    'GR(1) synthesizer using Cython.')
url = 'https://github.com/johnyf/{name}'.format(name=name)
README = 'README.md'
VERSION_FILE = '{name}/_version.py'.format(name=name)
MAJOR = 0
MINOR = 1
MICRO = 1
VERSION = '{major}.{minor}.{micro}'.format(
    major=MAJOR, minor=MINOR, micro=MICRO)
VERSION_TEXT = (
    '# This file was generated from setup.py\n'
    "version = '{version}'\n")
install_requires = [
    'dd >= 0.1.3',
    'omega >= 0.0.3']
tests_require = [
    'nose >= 1.3.4']


def git_version(version):
    try:
        import git
        repo = git.Repo('.git')
        repo.git.status()
    except ImportError, git.GitCommandNotFound:
        print('gitpython or git not found: Assume release.')
        return ''
    sha = repo.head.commit.hexsha
    if repo.is_dirty():
        return '.dev0+{sha}-dirty'.format(sha=sha)
    # commit is clean
    # is it release of `version` ?
    try:
        tag = repo.git.describe(
            match='v[0-9]*', exact_match=True,
            tags=True, dirty=True)
        assert tag[1:] == version, (tag, version)
        return ''
    except git.GitCommandError:
        return '.dev0+{sha}'.format(sha=sha)


def run_setup():
    # version
    version = VERSION + git_version(VERSION)
    s = VERSION_TEXT.format(version=version)
    with open(VERSION_FILE, 'w') as f:
        f.write(s)
    setup(
        name=name,
        version=version,
        description=description,
        long_description=open(README).read(),
        author='<NAME>',
        author_email='<EMAIL>',
{'fraction_non_alphanumeric': 0.15665488810365136, 'fraction_numerical': 0.012171181782489203, 'mean_word_length': 2.878234398782344, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '387595', 'n_tokens_mistral': 897, 'n_tokens_neox': 868, 'n_words': 187}