<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Setup script for the tables package"""

from __future__ import print_function

import os
import re
import sys
import ctypes
import tempfile
import textwrap
import subprocess
from os.path import exists, expanduser
import glob

# Using ``setuptools`` enables lots of goodies
from setuptools import setup, find_packages
import pkg_resources

from distutils.core import Extension
from distutils.dep_util import newer
from distutils.util import convert_path
from distutils.ccompiler import new_compiler

# We need to avoid importing numpy until we can be sure it's installed
# This approach is based on this SO answer http://stackoverflow.com/a/21621689
# This is also what pandas does.
from setuptools.command.build_ext import build_ext

# Fetch the requisites
with open('requirements.txt') as f:
    requirements = f.read().splitlines()

numpy_requirement = [r for r in requirements if 'numpy' in r]


class BuildExtensions(build_ext):
    """Subclass setuptools build_ext command

    BuildExtensions does two things
    1) it makes sure numpy is available
    2) it injects numpy's core/include directory in the include_dirs parameter
       of all extensions
    3) it runs the original build_ext command
    """

    def run(self):
        self.distribution.fetch_build_eggs(numpy_requirement)
        numpy_incl = pkg_resources.resource_filename('numpy', 'core/include')

        for ext in self.extensions:
            if (hasattr(ext, 'include_dirs') and
                    numpy_incl not in ext.include_dirs):
                ext.include_dirs.append(numpy_incl)

        build_ext.run(self)


cmdclass = {'build_ext': BuildExtensions}
setuptools_kwargs = {}

if sys.version_info >= (3,):
    fixer_names = [
        'lib2to3.fixes.fix_basestring',
        'lib2to3.fixes.fix_dict',
        'lib2to3.fixes.fix_imports',
        'lib2to3.fixes.fix_long',
        'lib2to3.fixes.fix_metaclass',
        'lib2to3.fixes.fix_next',
        'lib2to3.fixes.fix_numliterals',
        'lib2to3.fixes.fix_print',
        'lib2to3.fixes.fix_unicode',
        'lib2to3.fixes.fix_xrange',
    ]

    from lib2to3.refactor import get_fixers_from_package

    all_fixers = set(get_fixers_from_package('lib2to3.fixes'))
    exclude_fixers = sorted(all_fixers.difference(fixer_names))

    setuptools_kwargs['use_2to3'] = True
    setuptools_kwargs['use_2to3_fixers'] = []
    setuptools_kwargs['use_2to3_exclude_fixers'] = exclude_fixers

# The minimum required versions
min_python_version = (2, 6)
# Check for Python
if sys.version_info < min_python_version:
    exit_with_error("You need Python 2.6 or greater to install PyTables!")
print("* Using Python %s" % sys.version.splitlines()[0])

# Minumum equired versions for numpy, numexpr and HDF5
exec(open(os.path.join('tables', 'req_versions.py')).read())

# Some functions for showing errors and warnings.
def _print_admonition(kind, head, body):
    tw = textwrap.TextWrapper(initial_indent='   ', subsequent_indent='   ')

    print(".. %s:: %s" % (kind.upper(), head))
    for line in tw.wrap(body):
        print(line)


def exit_with_error(head, body=''):
    _print_admonition('error', head, body)
    sys.exit(1)


def print_warning(head, body=''):
    _print_admonition('warning', head, body)


VERSION = open('VERSION').read().strip()

# ----------------------------------------------------------------------

debug = '--debug' in sys.argv<commit_msg>Define the exit_with_error function before its invocation<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Setup script for the tables package"""

from __future__ import print_function

import os
import re
import sys
import ctypes
import tempfile
import textwrap
import subprocess
from os.path import exists, expanduser
import glob

# Using ``setuptools`` enables lots of goodies
from setuptools import setup, find_packages
import pkg_resources

from distutils.core import Extension
from distutils.dep_util import newer
from distutils.util import convert_path
from distutils.ccompiler import new_compiler

# We need to avoid importing numpy until we can be sure it's installed
# This approach is based on this SO answer http://stackoverflow.com/a/21621689
# This is also what pandas does.
from setuptools.command.build_ext import build_ext

# Fetch the requisites
with open('requirements.txt') as f:
    requirements = f.read().splitlines()

numpy_requirement = [r for r in requirements if 'numpy' in r]


class BuildExtensions(build_ext):
    """Subclass setuptools build_ext command

    BuildExtensions does two things
    1) it makes sure numpy is available
    2) it injects numpy's core/include directory in the include_dirs parameter
       of all extensions
    3) it runs the original build_ext command
    """

    def run(self):
        self.distribution.fetch_build_eggs(numpy_requirement)
        numpy_incl = pkg_resources.resource_filename('numpy', 'core/include')

        for ext in self.extensions:
            if (hasattr(ext, 'include_dirs') and
                    numpy_incl not in ext.include_dirs):
                ext.include_dirs.append(numpy_incl)

        build_ext.run(self)


cmdclass = {'build_ext': BuildExtensions}
setuptools_kwargs = {}

if sys.version_info >= (3,):
    fixer_names = [
        'lib2to3.fixes.fix_basestring',
        'lib2to3.fixes.fix_dict',
        'lib2to3.fixes.fix_imports',
        'lib2to3.fixes.fix_long',
        'lib2to3.fixes.fix_metaclass',
        'lib2to3.fixes.fix_next',
        'lib2to3.fixes.fix_numliterals',
        'lib2to3.fixes.fix_print',
        'lib2to3.fixes.fix_unicode',
        'lib2to3.fixes.fix_xrange',
    ]

    from lib2to3.refactor import get_fixers_from_package

    all_fixers = set(get_fixers_from_package('lib2to3.fixes'))
    exclude_fixers = sorted(all_fixers.difference(fixer_names))

    setuptools_kwargs['use_2to3'] = True
    setuptools_kwargs['use_2to3_fixers'] = []
    setuptools_kwargs['use_2to3_exclude_fixers'] = exclude_fixers


# Some functions for showing errors and warnings.
def _print_admonition(kind, head, body):
    tw = textwrap.TextWrapper(initial_indent='   ', subsequent_indent='   ')

    print(".. %s:: %s" % (kind.upper(), head))
    for line in tw.wrap(body):
        print(line)


def exit_with_error(head, body=''):
    _print_admonition('error', head, body)
    sys.exit(1)


def print_warning(head, body=''):
    _print_admonition('warning', head, body)


# The minimum required versions
min_python_version = (2, 6)
# Check for Python
if sys.version_info < min_python_version:
    exit_with_error("You need Python 2.6 or greater to install PyTables!")
print("* Using Python %s" % sys.version.splitlines()[0])

# Minumum equired versions for numpy, numexpr and HDF5
min_hdf5_version = None
exec(open(os.path.join('tables', 'req_versions.py')).read())


VERSION = open('VERSION').read().strip()

# ----------------------------------------------------------------------

debug = '--debug' in sys.argv
{'fraction_non_alphanumeric': 0.12061090493862403, 'fraction_numerical': 0.014416214673137312, 'mean_word_length': 3.4974326059050065, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2414164', 'n_tokens_mistral': 2265, 'n_tokens_neox': 2206, 'n_words': 573}