<commit_before># -*- coding: utf-8 -*-
# Copyright (c) 2013-2014 <NAME>
# All rights reserved.
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license.  See the LICENSE.txt file for details.
import os
import sys
import subprocess

from setuptools import setup


MAJOR = 0
MINOR = 5
MICRO = 0

IS_RELEASED = False

VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)


# Return the git revision as a string
def git_version():
    def _minimal_ext_cmd(cmd):
        # construct minimal environment
        env = {}
        for k in ['SYSTEMROOT', 'PATH']:
            v = os.environ.get(k)
            if v is not None:
                env[k] = v
        # LANGUAGE is used on win32
        env['LANGUAGE'] = 'C'
        env['LANG'] = 'C'
        env['LC_ALL'] = 'C'
        out = subprocess.Popen(
            cmd, stdout=subprocess.PIPE, env=env,
        ).communicate()[0]
        return out

    try:
        out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
        git_revision = out.strip().decode('ascii')
    except OSError:
        git_revision = "Unknown"

    try:
        out = _minimal_ext_cmd(['git', 'rev-list', '--count', 'HEAD'])
        git_count = out.strip().decode('ascii')
    except OSError:
        git_count = '0'

    return git_revision, git_count


def write_version_py(filename='haas/_version.py'):
    template = """\
# -*- coding: utf-8 -*-
# Copyright (c) 2013-2014 <NAME>
# All rights reserved.
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license.  See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals

# THIS FILE IS GENERATED FROM SETUP.PY
version = '{version}'
full_version = '{full_version}'
git_revision = '{git_revision}'
is_released = {is_released}

if not is_released:
    version = full_version
"""
    fullversion = VERSION
    if os.path.exists('.git'):
        git_rev, dev_num = git_version()
    elif os.path.exists('haas/_version.py'):
        # must be a source distribution, use existing version file
        try:
            from haas._version import git_revision as git_rev
        except ImportError:
            raise ImportError("Unable to import git_revision. Try removing "
                              "haas/_version.py and the build "
                              "directory before building.")
    else:
        git_rev = "Unknown"

    if not IS_RELEASED:
        fullversion += '.dev{0}+'.format(dev_num) + git_rev[:7]

    with open(filename, "wt") as fp:
        fp.write(template.format(version=VERSION,
                                 full_version=fullversion,
                                 git_revision=git_rev,
                                 is_released=IS_RELEASED))


if __name__ == "__main__":
    install_requires = ['stevedore', 'six']
    if sys.version_info < (2, 7):
        install_requires += ['unittest2', 'argparse', 'ordereddict']

    write_version_py()
    from haas import __version__

    with open('README.rst') as fh:
        long_description = fh.read()

    setup(
        name='haas',
        version=__version__,
        url='https://github.com/sjagoe/haas',
        author='<NAME>',
        author_email='<EMAIL>',
        classifiers=[
            'Development Status :: 3 - Alpha',
            'Intended Audience :: Developers',
            'License :: OSI Approved :: BSD License',
            'Operating System :: MacOS',
            'Operating System :: Microsoft :: Windows',
            'Operating System :: OS Independent',
            'Operating System :: POSIX',
            'Operating System :: Unix',
            'Programming Language :: Python',
            'Topic :: Software Development',
            'Topic :: Software Development :: Testing',
        ],
        description='Extensible Python Test Runner',
        long_description=long_description,
        license='BSD',
        packages=['haas', 'haas.plugins'],
        install_requires=install_requires,
        entry_points={
            'console_scripts': [
                'haas=haas.main:main',
            ],
            'haas.hooks.environment': [
                'coverage = haas.plugins.coverage:Coverage',
            ],
            'haas.runner': [
                'default = haas.plugins.runner:TextTestRunner',
            ],
        },
    )
<commit_msg>Fix setup.py for python 2.6<commit_after># -*- coding: utf-8 -*-
# Copyright (c) 2013-2014 <NAME>
# All rights reserved.
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license.  See the LICENSE.txt file for details.
import os
import sys
import subprocess

from setuptools import setup


MAJOR = 0
MINOR = 5
MICRO = 0

IS_RELEASED = False

VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)


# Return the git revision as a string
def git_version():
    def _minimal_ext_cmd(cmd):
        # construct minimal environment
        env = {}
        for k in ['SYSTEMROOT', 'PATH']:
            v = os.environ.get(k)
            if v is not None:
                env[k] = v
        # LANGUAGE is used on win32
        env['LANGUAGE'] = 'C'
        env['LANG'] = 'C'
        env['LC_ALL'] = 'C'
        out = subprocess.Popen(
            cmd, stdout=subprocess.PIPE, env=env,
        ).communicate()[0]
        return out

    try:
        out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
        git_revision = out.strip().decode('ascii')
    except OSError:
        git_revision = "Unknown"

    try:
        out = _minimal_ext_cmd(['git', 'rev-list', '--count', 'HEAD'])
        git_count = out.strip().decode('ascii')
    except OSError:
        git_count = '0'

    return git_revision, git_count


def write_version_py(filename='haas/_version.py'):
    template = """\
# -*- coding: utf-8 -*-
# Copyright (c) 2013-2014 <NAME>
# All rights reserved.
#
# This software may be modified and distributed under the terms
# of the 3-clause BSD license.  See the LICENSE.txt file for details.
from __future__ import absolute_import, unicode_literals

# THIS FILE IS GENERATED FROM SETUP.PY
version = '{version}'
full_version = '{full_version}'
git_revision = '{git_revision}'
is_released = {is_released}

if not is_released:
    version = full_version
"""
    fullversion = VERSION
    if os.path.exists('.git'):
        git_rev, dev_num = git_version()
    elif os.path.exists('haas/_version.py'):
        # must be a source distribution, use existing version file
        try:
            from haas._version import git_revision as git_rev
            from haas._version import full_version as full_v
        except ImportError:
            raise ImportError("Unable to import git_revision. Try removing "
                              "haas/_version.py and the build "
                              "directory before building.")
        import re
        match = re.match(r'.*?\.dev(?P<dev_num>\d+)\+.*', full_v)
        if match is None:
            dev_num = '0'
        else:
            dev_num = match.group('dev_num')
    else:
        git_rev = "Unknown"
        dev_num = '0'

    if not IS_RELEASED:
        fullversion += '.dev{0}+'.format(dev_num) + git_rev[:7]

    with open(filename, "wt") as fp:
        fp.write(template.format(version=VERSION,
                                 full_version=fullversion,
                                 git_revision=git_rev,
                                 is_released=IS_RELEASED))


if __name__ == "__main__":
    install_requires = ['stevedore', 'six']
    if sys.version_info < (2, 7):
        install_requires += ['unittest2', 'argparse', 'ordereddict']

    write_version_py()
    from haas import __version__

    with open('README.rst') as fh:
        long_description = fh.read()

    setup(
        name='haas',
        version=__version__,
        url='https://github.com/sjagoe/haas',
        author='<NAME>',
        author_email='<EMAIL>',
        classifiers=[
            'Development Status :: 3 - Alpha',
            'Intended Audience :: Developers',
            'License :: OSI Approved :: BSD License',
            'Operating System :: MacOS',
            'Operating System :: Microsoft :: Windows',
            'Operating System :: OS Independent',
            'Operating System :: POSIX',
            'Operating System :: Unix',
            'Programming Language :: Python',
            'Topic :: Software Development',
            'Topic :: Software Development :: Testing',
        ],
        description='Extensible Python Test Runner',
        long_description=long_description,
        license='BSD',
        packages=['haas', 'haas.plugins'],
        install_requires=install_requires,
        entry_points={
            'console_scripts': [
                'haas=haas.main:main',
            ],
            'haas.hooks.environment': [
                'coverage = haas.plugins.coverage:Coverage',
            ],
            'haas.runner': [
                'default = haas.plugins.runner:TextTestRunner',
            ],
        },
    )

{'fraction_non_alphanumeric': 0.11942286348501664, 'fraction_numerical': 0.00776914539400666, 'mean_word_length': 2.0880740233036326, 'pattern_counts': {'":': 2, '<': 14, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1605329', 'n_tokens_mistral': 2745, 'n_tokens_neox': 2621, 'n_words': 692}