<commit_before>#!/usr/bin/env python

###############################################################################
# Copyright (c) 2014-2016 Center for Advanced Studies,
#                         Research and Development in Sardinia (CRS4)
# 
# Licensed under the terms of the MIT License (see LICENSE file included with the
# project).
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
###############################################################################

from glob import glob
import os
import sys

from setuptools import setup, Extension

from distutils.command.build import build
from distutils.command.build_ext import build_ext
from setuptools.command.install import install
from distutils.command.clean import clean
from distutils import log

def find_swig():
    for path in os.environ['PATH'].split(os.pathsep):
        swigs = glob(os.path.join(path, 'swig*'))
        if swigs:
            return swigs[0]
    return None

class CustomBuildExt(build_ext):
    """
    Custom build_ext used merely to inject code to find the swig executable.
    """
    def finalize_options(self):
        build_ext.finalize_options(self)
        log.info("Running CustomBuildExt.finalize_options")
        if not self.swig:
            self.swig = find_swig()
            log.info("Using swig found at %s", self.swig)


class CustomBuild(build):
    """
    Build project reordering steps:  run build_ext before build_py.

    This is necessary because pyrapi/rapi.py is generated by swig,
    which is run by build_ext.

    Fix courtesy of `<NAME> <http://stackoverflow.com/questions/12491328/python-distutils-not-include-the-swig-generated-module>`_.
    """
    def run(self):
        log.info("Running CustomBuild")
        self.run_command('build_ext')
        build.run(self)


class CustomInstall(install):
    def run(self):
        log.info("Running CustomInstall")
        self.run_command('build_ext')
        self.do_egg_install()

class CustomClean(clean):
    def run(self):
        log.info("Running CustomClean")
        my_dir = os.path.dirname(__file__)
        for pattern in ('rapi.py', 'rapi.pyc', 'pyrapi_wrap.*', '_rapi.so'):
            for f in glob(os.path.join(my_dir, 'pyrapi', pattern)):
                log.info("Removing %s", f)
                os.remove(f)
        clean.run(self)


pyrapi_dir = os.path.dirname(os.path.abspath(__file__))
ProjectRoot = os.path.abspath(os.path.join(pyrapi_dir, "../.."))
print >> sys.stderr, "Project root:", ProjectRoot

bwa_rapi_extension = Extension(
    'pyrapi._rapi', ['pyrapi/pyrapi.i'],
    swig_opts=['-builtin', '-I%s' % os.path.join(ProjectRoot, 'include'), ],
    include_dirs=[os.path.join(ProjectRoot, 'include')],
    library_dirs=[os.path.join(ProjectRoot, 'rapi_bwa')],
    libraries=['rapi_bwa', 'z'],
    extra_compile_args=['-std=c99'])


setup(
    cmdclass={
        'build': CustomBuild,
        'build_ext': CustomBuildExt,
        'install': CustomInstall,
        'clean':  CustomClean,
    },
    name="pyrapi",
    version='0.0.1',
    description="Python bindings for RAPI",
    author="<NAME>",
    author_email="<EMAIL>",
    url="https://github.com/ilveroluca/rapi",
    packages=['pyrapi'],
    ext_modules=[
        bwa_rapi_extension
    ],
    py_modules=[
        'pyrapi.rapi'
    ],
    classifiers=[
        "Programming Language :: Python",
        "Operating System :: POSIX :: Linux",
    ],
)
<commit_msg>More complete clean procedure for pyrapi<commit_after>#!/usr/bin/env python

###############################################################################
# Copyright (c) 2014-2016 Center for Advanced Studies,
#                         Research and Development in Sardinia (CRS4)
# 
# Licensed under the terms of the MIT License (see LICENSE file included with the
# project).
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
###############################################################################

from glob import glob
import os
import shutil
import sys

from setuptools import setup, Extension

from distutils.command.build import build
from distutils.command.build_ext import build_ext
from setuptools.command.install import install
from distutils.command.clean import clean
from distutils import log

def find_swig():
    for path in os.environ['PATH'].split(os.pathsep):
        swigs = glob(os.path.join(path, 'swig*'))
        if swigs:
            return swigs[0]
    return None

class CustomBuildExt(build_ext):
    """
    Custom build_ext used merely to inject code to find the swig executable.
    """
    def finalize_options(self):
        build_ext.finalize_options(self)
        log.info("Running CustomBuildExt.finalize_options")
        if not self.swig:
            self.swig = find_swig()
            log.info("Using swig found at %s", self.swig)


class CustomBuild(build):
    """
    Build project reordering steps:  run build_ext before build_py.

    This is necessary because pyrapi/rapi.py is generated by swig,
    which is run by build_ext.

    Fix courtesy of `<NAME> <http://stackoverflow.com/questions/12491328/python-distutils-not-include-the-swig-generated-module>`_.
    """
    def run(self):
        log.info("Running CustomBuild")
        self.run_command('build_ext')
        build.run(self)


class CustomInstall(install):
    def run(self):
        log.info("Running CustomInstall")
        self.run_command('build_ext')
        self.do_egg_install()

class CustomClean(clean):
    def run(self):
        log.info("Running CustomClean")
        my_dir = os.path.dirname(__file__)
        for pattern in ('rapi.py', 'rapi.pyc', 'pyrapi_wrap.*', '_rapi.so'):
            for f in glob(os.path.join(my_dir, 'pyrapi', pattern)):
                log.info("Removing %s", f)
                os.remove(f)
        for dirname in ('dist', 'pyrapi.egg-info'):
            shutil.rmtree(dirname, ignore_errors=True)
        clean.run(self)


pyrapi_dir = os.path.dirname(os.path.abspath(__file__))
ProjectRoot = os.path.abspath(os.path.join(pyrapi_dir, "../.."))
print >> sys.stderr, "Project root:", ProjectRoot

bwa_rapi_extension = Extension(
    'pyrapi._rapi', ['pyrapi/pyrapi.i'],
    swig_opts=['-builtin', '-I%s' % os.path.join(ProjectRoot, 'include'), ],
    include_dirs=[os.path.join(ProjectRoot, 'include')],
    library_dirs=[os.path.join(ProjectRoot, 'rapi_bwa')],
    libraries=['rapi_bwa', 'z'],
    extra_compile_args=['-std=c99'])


setup(
    cmdclass={
        'build': CustomBuild,
        'build_ext': CustomBuildExt,
        'install': CustomInstall,
        'clean':  CustomClean,
    },
    name="pyrapi",
    version='0.0.1',
    description="Python bindings for RAPI",
    author="<NAME>",
    author_email="<EMAIL>",
    url="https://github.com/ilveroluca/rapi",
    packages=['pyrapi'],
    ext_modules=[
        bwa_rapi_extension
    ],
    py_modules=[
        'pyrapi.rapi'
    ],
    classifiers=[
        "Programming Language :: Python",
        "Operating System :: POSIX :: Linux",
    ],
)

{'fraction_non_alphanumeric': 0.15499235863474273, 'fraction_numerical': 0.0058583800305654615, 'mean_word_length': 3.281897491821156, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1969100', 'n_tokens_mistral': 2439, 'n_tokens_neox': 2349, 'n_words': 632}