<commit_before>'''
  Numberjack is a constraint satisfaction and optimisation library
  Copyright (C) 2009-2013 Cork Constraint Computation Center, UCC

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

  The authors can be contacted electronically at
  <EMAIL>
'''


from distutils.core import setup
from distutils.extension import Extension
from distutils.command.build_ext import build_ext as _build_ext
from distutils.errors import CCompilerError
import subprocess as sp
import sys
import os


EXTRA_COMPILE_ARGS = ['-O3']
EXTRA_LINK_ARGS = []
extensions = []
disabled_extensions = []

if sys.platform == 'darwin':
    EXTRA_COMPILE_ARGS.extend(
        ['-stdlib=libstdc++', '-Wno-shorten-64-to-32',
         '-arch', 'x86_64',  # force 64bit only builds on Mac

         # ignore warnings about swig code
         '-Wno-self-assign', '-Wno-shadow', '-Wno-unused-label',
         ])
    EXTRA_LINK_ARGS.extend(['-arch', 'x86_64', '-stdlib=libstdc++'])
elif sys.platform.startswith('linux'):
    EXTRA_COMPILE_ARGS.extend(['-Wno-narrowing'])


class njbuild_ext(_build_ext):
    # Allow for C extension compilation to fail.

    def __init__(self, *args, **kwargs):
        self.builtsolvernames = []
        self.compile_msgs = []
        _build_ext.__init__(self, *args, **kwargs)

    def run(self):
        _build_ext.run(self)

        if disabled_extensions:
            print >> sys.stderr, \
                "The following solvers could not be located " \
                "on your system so their interface has been disabled:", \
                ", ".join(disabled_extensions)

        for msg in self.compile_msgs:
            print >> sys.stderr, msg

        if self.builtsolvernames:
            print "Successfully built solver interfaces for", \
                ", ".join(self.builtsolvernames)

    def build_extension(self, ext):
        try:
            _build_ext.build_extension(self, ext)

            # Record the names of extensions which were successful, trim '_'
            self.builtsolvernames.append(ext.name[1:])

        except CCompilerError:
            self.compile_msgs.append(
                "Failed to build %s solver interface, details are above." %
                ext.name
            )


# ------------------------------ Helper Methods ------------------------------


def xml2config(option, path="xml2-config"):
    import shlex
    cmd = '%s %s' % (path, option)
    p = sp.Popen(cmd, stdout=sp.PIPE, shell=True)
    stdout, stderr = p.communicate()
    return shlex.split(stdout.strip())


CPLEX, GUROBI, SCIP = "CPLEX", "Gurobi", "SCIP"


def get_solver_home(solvername):
    # Helps to find the path to a particular third party solver
    from distutils.spawn import find_executable

    if solvername == CPLEX:
        # Try for environmental variable first
        env_path = os.getenv('CPLEXDIR')
        if env_path and len(env_path.strip()) > 0:
            return env_path

        # Try to find the cplex binary in the PATH
        ex_path = find_executable('cplex')
        if ex_path:
            ex_path = os.path.realpath(ex_path)  # Expand symbolic links if any
            ex_dir = os.path.dirname(ex_path)  # Path to the bin directory
            return os.path.abspath(os.path.join(ex_dir, os.pardir, os.pardir))

    elif solvername == GUROBI:
        # Try for environmental variable first
        env_path = os.getenv('GUROBI_HOME')
        if env_path and len(env_path.strip()) > 0:
            return env_path

        # Try to find the gurobi_cl binary in the PATH
        ex_path = find_executable('gurobi_cl')
        if ex_path:
            ex_path = os.path.realpath(ex_path)  # Expand symbolic links if any
            ex_dir = os.path.dirname(ex_path)  # Path to the bin directory
            return os.path.abspath(os.path.join(ex_dir, os.pardir))

    elif solvername == SCIP:
        # Try for environmental variable first
        env_path = os.getenv('ZIBPATH')
        if env_path and len(env_path.strip()) > 0:
            return env_path

        # Otherwise, if the tgz has been placed in this directory, extract it
        # and return that folder's path
        scipoptfolder = None
        for basename in os.listdir(os.getcwd()):
            if os.path.isfile(basename) and \
                    basename.startswith("scipoptsuite-") and \
                    basename.endswith(".tgz"):
                # print "Found", basename, "extracting."
                scipoptfolder = os.path.join(os.getcwd(), basename[:-4])
                if not os.path.isdir(scipoptfolder):
                    sp.call('tar zxf %s' % basename,
                            cwd=os.getcwd(), shell=True)
                break
        return scipoptfolder

    else:
        raise RuntimeError("Error unknown solver name '%s'" % solvername)<commit_msg>Tidy comment.<commit_after>'''
  Numberjack is a constraint satisfaction and optimisation library
  Copyright (C) 2009-2013 Cork Constraint Computation Center, UCC

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

  The authors can be contacted electronically at
  <EMAIL>
'''


from distutils.core import setup
from distutils.extension import Extension
from distutils.command.build_ext import build_ext as _build_ext
from distutils.errors import CCompilerError
import subprocess as sp
import sys
import os


EXTRA_COMPILE_ARGS = ['-O3']
EXTRA_LINK_ARGS = []
extensions = []
disabled_extensions = []

if sys.platform == 'darwin':
    EXTRA_COMPILE_ARGS.extend(
        ['-stdlib=libstdc++', '-Wno-shorten-64-to-32',
         '-arch', 'x86_64',  # force 64bit only builds on Mac

         # ignore warnings about swig code
         '-Wno-self-assign', '-Wno-shadow', '-Wno-unused-label',
         ])
    EXTRA_LINK_ARGS.extend(['-arch', 'x86_64', '-stdlib=libstdc++'])
elif sys.platform.startswith('linux'):
    EXTRA_COMPILE_ARGS.extend(['-Wno-narrowing'])


class njbuild_ext(_build_ext):
    # Allow for C extension compilation to fail.

    def __init__(self, *args, **kwargs):
        self.builtsolvernames = []
        self.compile_msgs = []
        _build_ext.__init__(self, *args, **kwargs)

    def run(self):
        _build_ext.run(self)

        if disabled_extensions:
            print >> sys.stderr, \
                "The following solvers could not be located " \
                "on your system so their interface has been disabled:", \
                ", ".join(disabled_extensions)

        for msg in self.compile_msgs:
            print >> sys.stderr, msg

        if self.builtsolvernames:
            print "Successfully built solver interfaces for", \
                ", ".join(self.builtsolvernames)

    def build_extension(self, ext):
        try:
            _build_ext.build_extension(self, ext)

            # Record the names of extensions which were successful, trim '_'
            self.builtsolvernames.append(ext.name[1:])

        except CCompilerError:
            self.compile_msgs.append(
                "Failed to build %s solver interface, details are above." %
                ext.name
            )


# ------------------------------ Helper Methods ------------------------------


def xml2config(option, path="xml2-config"):
    import shlex
    cmd = '%s %s' % (path, option)
    p = sp.Popen(cmd, stdout=sp.PIPE, shell=True)
    stdout, stderr = p.communicate()
    return shlex.split(stdout.strip())


CPLEX, GUROBI, SCIP = "CPLEX", "Gurobi", "SCIP"


def get_solver_home(solvername):
    # Helps to find the path to a particular third party solver
    from distutils.spawn import find_executable

    if solvername == CPLEX:
        # Try for environmental variable first
        env_path = os.getenv('CPLEXDIR')
        if env_path and len(env_path.strip()) > 0:
            return env_path

        # Try to find the cplex binary in the PATH
        ex_path = find_executable('cplex')
        if ex_path:
            ex_path = os.path.realpath(ex_path)  # Expand symbolic links if any
            ex_dir = os.path.dirname(ex_path)  # Path to the bin directory
            return os.path.abspath(os.path.join(ex_dir, os.pardir, os.pardir))

    elif solvername == GUROBI:
        # Try for environmental variable first
        env_path = os.getenv('GUROBI_HOME')
        if env_path and len(env_path.strip()) > 0:
            return env_path

        # Try to find the gurobi_cl binary in the PATH
        ex_path = find_executable('gurobi_cl')
        if ex_path:
            ex_path = os.path.realpath(ex_path)  # Expand symbolic links if any
            ex_dir = os.path.dirname(ex_path)  # Path to the bin directory
            return os.path.abspath(os.path.join(ex_dir, os.pardir))

    elif solvername == SCIP:
        # Try for environmental variable first
        env_path = os.getenv('ZIBPATH')
        if env_path and len(env_path.strip()) > 0:
            return env_path

        # Otherwise, if the tgz has been placed in this directory, extract it
        # and return that folder's path
        scipoptfolder = None
        for basename in os.listdir(os.getcwd()):
            if os.path.isfile(basename) and \
                    basename.startswith("scipoptsuite-") and \
                    basename.endswith(".tgz"):
                scipoptfolder = os.path.join(os.getcwd(), basename[:-4])
                if not os.path.isdir(scipoptfolder):
                    sp.call('tar zxf %s' % basename,
                            cwd=os.getcwd(), shell=True)
                break
        return scipoptfolder

    else:
        raise RuntimeError("Error unknown solver name '%s'" % solvername)
{'fraction_non_alphanumeric': 0.10088884816274168, 'fraction_numerical': 0.007697241821680564, 'mean_word_length': 2.357120885881267, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '6969390', 'n_tokens_mistral': 3290, 'n_tokens_neox': 3117, 'n_words': 994}