<commit_before># Copyright (c) <NAME> <_<EMAIL>>
# See COPYING for details.

from distutils.command.build_ext import build_ext
from distutils.core import setup
from distutils.extension import Extension
import os
import subprocess

# silence, pyflakes.
build_ext = build_ext


# select keccak implementation from the environment or trying to autodetect a
# 32- vs. 64-bit host.
keccak_implementation = os.environ.get('CYKECCAK_IMPLEMENTATION')
if keccak_implementation is None:
    import struct
    if struct.calcsize('P') == 8:
        keccak_implementation = 'opt64'
    else:
        keccak_implementation = 'opt32'


# try to pull the version from git, or fall back on a previously-saved version.
try:
    proc = subprocess.Popen(['git', 'describe', '--tags', '--long'],
                            stdout=subprocess.PIPE)
except OSError:
    print "couldn't determine version from git; using version.txt"
    with open('version.txt', 'rb') as infile:
        raw_version = infile.read()
else:
    raw_version = proc.communicate()[0].strip()
    with open('version.txt', 'wb') as outfile:
        outfile.write(raw_version)


# parse the git-described verion into something usable.
tag_version, commits, sha = raw_version.rsplit('-', 2)
if commits == '0':
    version = tag_version
else:
    version = '%s.dev%s' % (tag_version, commits)


# set up the extension with the version and keccak sources.
keccak_extension = Extension(
    'keccak',
    ['src/KeccakSponge.c', 'src/KeccakF-1600-%s.c' % (keccak_implementation,)],
    include_dirs=['src'],
    define_macros=[('CYKECCAK_VERSION', '"%s"' % (version,)),
                   ('CYKECCAK_SHA', '"%s"' % (sha.lstrip('g'),))],
)


# add the cython source in its .pyx or .c form.
try:
    from Cython.Distutils import build_ext
except ImportError:
    if not os.path.exists('keccak.c'):
        print "cython not usable and no cython'd files present."
        print "are you installing from a git clone or github tarball?"
        raise
    print "cython not usable; using previously-cython'd .c file."
    keccak_extension.sources.append('keccak.c')
else:
    keccak_extension.sources.append('keccak.pyx')


with open('README', 'rb') as infile:
    long_description = infile.read()

setup(
    name='cykeccak',
    version=version,
    description='Cython bindings to the Keccak sponge function',
    long_description=long_description,
    author='<NAME>',
    author_email='_<EMAIL>',
    url='https://github.com/habnabit/cykeccak',
    classifiers=[
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: ISC License (ISCL)',
        'Operating System :: POSIX',
        'Programming Language :: Cython',
        'Programming Language :: C',
        'Programming Language :: Python :: 2.6',
        'Programming Language :: Python :: 2.7',
        'Topic :: Security :: Cryptography',<commit_msg>Clarifying some setup.py error cases.<commit_after># Copyright (c) <NAME> <_<EMAIL>>
# See COPYING for details.

from distutils.command.build_ext import build_ext
from distutils.core import setup
from distutils.extension import Extension
import os
import subprocess

# silence, pyflakes.
build_ext = build_ext


# select keccak implementation from the environment or trying to autodetect a
# 32- vs. 64-bit host.
keccak_implementation = os.environ.get('CYKECCAK_IMPLEMENTATION')
if keccak_implementation is None:
    import struct
    if struct.calcsize('P') == 8:
        keccak_implementation = 'opt64'
    else:
        keccak_implementation = 'opt32'


# try to pull the version from git, or fall back on a previously-saved version.
try:
    proc = subprocess.Popen(['git', 'describe', '--tags', '--long'],
                            stdout=subprocess.PIPE)
except OSError:
    if not os.path.exists('version.txt'):
        print "git-describe failed and version.txt isn't present."
        print "are you installing from a github tarball?"
        raise
    print "couldn't determine version from git; using version.txt"
    with open('version.txt', 'rb') as infile:
        raw_version = infile.read()
else:
    raw_version = proc.communicate()[0].strip()
    with open('version.txt', 'wb') as outfile:
        outfile.write(raw_version)


# parse the git-described verion into something usable.
tag_version, commits, sha = raw_version.rsplit('-', 2)
if commits == '0':
    version = tag_version
else:
    version = '%s.dev%s' % (tag_version, commits)


# set up the extension with the version and keccak sources.
keccak_extension = Extension(
    'keccak',
    ['src/KeccakSponge.c', 'src/KeccakF-1600-%s.c' % (keccak_implementation,)],
    include_dirs=['src'],
    define_macros=[('CYKECCAK_VERSION', '"%s"' % (version,)),
                   ('CYKECCAK_SHA', '"%s"' % (sha.lstrip('g'),))],
)


# add the cython source in its .pyx or .c form.
try:
    from Cython.Distutils import build_ext
except ImportError:
    if not os.path.exists('keccak.c'):
        print "cython isn't usable and pre-cython'd files aren't present."
        print "are you installing from a git clone or github tarball?"
        raise
    print "cython not usable; using previously-cython'd .c file."
    keccak_extension.sources.append('keccak.c')
else:
    keccak_extension.sources.append('keccak.pyx')


with open('README', 'rb') as infile:
    long_description = infile.read()

setup(
    name='cykeccak',
    version=version,
    description='Cython bindings to the Keccak sponge function',
    long_description=long_description,
    author='<NAME>',
    author_email='_<EMAIL>',
    url='https://github.com/habnabit/cykeccak',
    classifiers=[
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: ISC License (ISCL)',
        'Operating System :: POSIX',
        'Programming Language :: Cython',
        'Programming Language :: C',
        'Programming Language :: Python :: 2.6',
        'Programming Language :: Python :: 2.7',
        'Topic :: Security :: Cryptography',
{'fraction_non_alphanumeric': 0.1267954432887568, 'fraction_numerical': 0.006934125804853888, 'mean_word_length': 3.336435218324982, 'pattern_counts': {'":': 0, '<': 13, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1099618', 'n_tokens_mistral': 1983, 'n_tokens_neox': 1878, 'n_words': 540}