Compile libfaketime.
175802
def run(self):
        """"""
        if sys.platform == "linux" or sys.platform == "linux2":
            libname = 'libfaketime.so.1'
            libnamemt = 'libfaketimeMT.so.1'
        elif sys.platform == "darwin":
            libname = 'libfaketime.1.dylib'
            libnamemt = 'libfaketimeMT.1.dylib'
        else:
            sys.stderr.write("WARNING : libfaketime does not support platform {}\n".format(sys.platform))
            sys.stderr.flush()
            return

        faketime_lib = join('faketime', libname)
        faketime_lib_mt = join('faketime', libnamemt)
        self.my_outputs = []

        setup_py_directory = dirname(realpath(__file__))
        faketime_directory = join(setup_py_directory, "faketime")
        os.chdir(faketime_directory)
        if sys.platform == "linux" or sys.platform == "linux2":
            subprocess.check_call(['make',])
        else:
            os.chdir(setup_py_directory)
            if "10.12" in subprocess.check_output(["sw_vers", "-productVersion"]).decode('utf8'):
                self.copy_file(
                    join('faketime', "libfaketime.c.sierra"),
                    join('faketime', "libfaketime.c")
                )

            os.chdir(faketime_directory)
            subprocess.check_call(['make', '-f', 'Makefile.OSX'])
        os.chdir(setup_py_directory)

        dest = join(self.install_purelib, dirname(faketime_lib))
        dest_mt = join(self.install_purelib, dirname(faketime_lib_mt))

        try:
            os.makedirs(dest)
        except OSError as e:
            if e.errno != 17:
                raise
        self.copy_file(faketime_lib, dest)

        if exists(faketime_lib_mt):
            self.copy_file(faketime_lib_mt, dest_mt)
        self.my_outputs.append(join(dest, libname))

        install.run(self)
18111
def libvlc_free(ptr):
    '''
    '''
    f = _Cfunctions.get('libvlc_free', None) or \
        _Cfunction('libvlc_free', ((1,),), None,
                    None, ctypes.c_void_p)
    return f(ptr)
1077542
def p_compilerDirective(p):
    """'"""
    directive = p[3].lower()
    param = p[5]
    if directive == 'include':
        fname = param
        if p.parser.file:
            if os.path.dirname(p.parser.file):
                fname = os.path.join(os.path.dirname(p.parser.file),
                                     fname)
        p.parser.mofcomp.compile_file(fname, p.parser.handle.default_namespace)
    elif directive == 'namespace':
        p.parser.handle.default_namespace = param
        if param not in p.parser.qualcache:
            p.parser.qualcache[param] = NocaseDict()

    p[0] = None
10948
def do_library(self, args):
        """"""
        func = getattr(args, 'func', None)
        if func is not None:
            # Call whatever subcommand function was selected
            func(self, args)
        else:
            # No subcommand was provided, so call help
            self.do_help('library')
992570
def build(python=PYTHON):
    """"""
    clean()
    local(
        "LIBRARY_PATH={library_path} CPATH={include_path} {python} "
        "setup.py build_ext --inplace".format(
            library_path=LIBRARY_PATH,
            include_path=INCLUDE_PATH,
            python=python,
        ))
1369171
def installFuncVersionedLib(target, source, env):
    """"""
    try:
        install = env['INSTALLVERSIONEDLIB']
    except KeyError:
        raise SCons.Errors.UserError('Missing INSTALLVERSIONEDLIB construction variable.')

    assert len(target)==len(source), \
           "Installing source %s into target %s: target and source lists must have same length."%(list(map(str, source)), list(map(str, target)))
    for t,s in zip(target,source):
        if hasattr(t.attributes, 'shlibname'):
            tpath = os.path.join(t.get_dir(), t.attributes.shlibname)
        else:
            tpath = t.get_path()
        if install(tpath,s.get_path(),env):
            return 1

    return 0
941066
def compile(self, source, dest, is_two_file=True, post=None, lang=None):
        """"""
        makedirs(os.path.dirname(dest))
        with io.open(dest, "w+", encoding="utf8") as out_file:
            with io.open(source, "r", encoding="utf8") as in_file:
                data = in_file.read()
            data, shortcode_deps = self.compile_string(data, source, is_two_file, post, lang)
            out_file.write(data)
        if post is None:
            if shortcode_deps:
                self.logger.error(
                    "Cannot save dependencies for post {0} (post unknown)",
                    source)
        else:
            post._depfile[dest] += shortcode_deps
        return True
792471
def compile_binary(source):
    
    cmd = 'make sense'
    src = '/usr/local/bin/chkrootkit'
    dst = '/usr/local/chkrootkit/chkrootkit'
    # Tar Extraction
    t = tarfile.open(source, 'r')
    t.extractall(TMPDIR)
    if isinstance(t.getnames(), list):
        extract_dir = t.getnames()[0].split('/')[0]
        os.chdir(TMPDIR + '/' + extract_dir)
        logger.info('make output: \n%s' % subprocess.getoutput(cmd))
        # move directory in place
        mv_cmd = 'sudo mv %s /usr/local/chkrootkit' % (TMPDIR + '/' + extract_dir)
        subprocess.getoutput(mv_cmd)
        # create symlink to binary in directory
        os.symlink(dst, src)
        return True
    return False
11946
def _load_lib():
    """"""
    lib_path = _find_lib_path()
    lib = ctypes.cdll.LoadLibrary(lib_path[0])
    # DMatrix functions
    lib.MXGetLastError.restype = ctypes.c_char_p
    return lib
180455
def configuration(parent_package='', top_path=None):
    """"""
    config = Configuration('', parent_package, top_path)

    F95FLAGS = get_compiler_flags()

    kwargs = {
        'libraries': [],
        'include_dirs': [],
        'library_dirs': [],
    }
    kwargs['extra_compile_args'] = F95FLAGS
    kwargs['f2py_options'] = ['--quiet']

    # numpy.distutils.fcompiler.FCompiler doesn't support .F95 extension
    compiler = FCompiler(get_default_fcompiler())
    compiler.src_extensions.append('.F95')
    compiler.language_map['.F95'] = 'f90'

    # collect all Fortran sources
    files = os.listdir('src')
    exclude_sources = ['PlanetsConstants.f95', 'PythonWrapper.f95']
    sources = [os.path.join('src', file) for file in files if
               file.lower().endswith(('.f95', '.c')) and file not in
               exclude_sources]

    # (from http://stackoverflow.com/questions/14320220/
    #              testing-python-c-libraries-get-build-path)):
    build_lib_dir = "{dirname}.{platform}-{version[0]}.{version[1]}"
    dirparams = {'dirname': 'temp',
                 'platform': sysconfig.get_platform(),
                 'version': sys.version_info}
    libdir = os.path.join('build', build_lib_dir.format(**dirparams))
    print('searching SHTOOLS in:', libdir)

    # Fortran compilation
    config.add_library('SHTOOLS',
                       sources=sources,
                       **kwargs)

    # SHTOOLS
    kwargs['libraries'].extend(['SHTOOLS'])
    kwargs['include_dirs'].extend([libdir])
    kwargs['library_dirs'].extend([libdir])

    # FFTW info
    fftw_info = get_info('fftw', notfound_action=2)
    dict_append(kwargs, **fftw_info)

    if sys.platform != 'win32':
        kwargs['libraries'].extend(['m'])

    # BLAS / Lapack info
    lapack_info = get_info('lapack_opt', notfound_action=2)
    blas_info = get_info('blas_opt', notfound_action=2)
    dict_append(kwargs, **blas_info)
    dict_append(kwargs, **lapack_info)

    config.add_extension('pyshtools._SHTOOLS',
                         sources=['src/pyshtools.pyf',
                                  'src/PythonWrapper.f95'],
                         **kwargs)

    return config
811875
def time_calls_with_dims(**dims):
    """"""
    def time_wrapper(fn):
        @functools.wraps(fn)
        def fn_wrapper(*args, **kwargs):
            _timer = timer("%s_calls" %
                           pyformance.registry.get_qualname(fn), **dims)
            with _timer.time(fn=pyformance.registry.get_qualname(fn)):
                return fn(*args, **kwargs)
        return fn_wrapper
    return time_wrapper
271981
def optimize(self):
        
        # load benchmarks results
        with open(LIBRARIES_FILE, 'r') as f:
            libs_data = json.load(f)
        # optimize
        for alg, libs_names in libs_data.items():
            libs = self.get_libs(alg)
            if not libs:
                continue
            # drop slow libs
            self.libs[alg] = [lib for lib in libs if [lib.module_name, lib.func_name] in libs_names]
            # sort libs by speed
            self.libs[alg].sort(key=lambda lib: libs_names.index([lib.module_name, lib.func_name]))
634983
def lib(names, sources=[], requirements=[], default_build=[], usage_requirements=[]):
    """"""
    assert is_iterable_typed(names, basestring)
    assert is_iterable_typed(sources, basestring)
    assert is_iterable_typed(requirements, basestring)
    assert is_iterable_typed(default_build, basestring)
    assert is_iterable_typed(usage_requirements, basestring)
    if len(names) > 1:
        if any(r.startswith('<name>') for r in requirements):
            get_manager().errors()("When several names are given to the 'lib' rule\n" +
                                   "it is not allowed to specify the <name> feature.")

        if sources:
            get_manager().errors()("When several names are given to the 'lib' rule\n" +
                                   "it is not allowed to specify sources.")

    project = get_manager().projects().current()
    result = []

    for name in names:
        r = requirements[:]

        # Support " lib a ; " and " lib a b c ; " syntax.
        if not sources and not any(r.startswith("<name>") for r in requirements) \
           and not any(r.startswith("<file") for r in requirements):
            r.append("<name>" + name)

        result.append(targets.create_typed_metatarget(name, "LIB", sources,
                                                      r,
                                                      default_build,
                                                      usage_requirements))
    return result
1344757
def build(self, build_dir, **kwargs):
        """"""
        # pylint: disable=no-self-use
        del kwargs
        args = ["cmake", "--build", build_dir]
        args.extend(self._get_build_flags())
        return [{"args": args}]
525454
def make_relative_timing_fn():
  """"""
  start_time = time.time()

  def format_relative_time():
    time_delta = time.time() - start_time
    return str(datetime.timedelta(seconds=time_delta))

  def log_relative_time():
    tf.logging.info("Timing: %s", format_relative_time())

  return log_relative_time
5311
def apply_fixes(args, tmpdir):
  """"""
  invocation = [args.clang_apply_replacements_binary]
  if args.format:
    invocation.append('-format')
  if args.style:
    invocation.append('-style=' + args.style)
  invocation.append(tmpdir)
  subprocess.call(invocation)
812417
def compile_(self):
        """"""
        from Cython import Build
        argv = copy.deepcopy(sys.argv)
        sys.argv = [sys.argv[0], 'build_ext', '--build-lib='+self.buildpath]
        exc_modules = [
                distutils.extension.Extension(
                        'hydpy.cythons.autogen.'+self.cyname,
                        [self.pyxfilepath], extra_compile_args=['-O2'])]
        distutils.core.setup(ext_modules=Build.cythonize(exc_modules),
                             include_dirs=[numpy.get_include()])
        sys.argv = argv