當前位置: 首頁>>代碼示例>>Python>>正文


Python numpy.distutils方法代碼示例

本文整理匯總了Python中numpy.distutils方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.distutils方法的具體用法?Python numpy.distutils怎麽用?Python numpy.distutils使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在numpy的用法示例。


在下文中一共展示了numpy.distutils方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: todict

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def todict(self):
        """
        Return a dictionary compatible with the keyword arguments of distutils
        setup function.

        Examples
        --------
        >>> setup(**config.todict())                           #doctest: +SKIP
        """

        self._optimize_data_files()
        d = {}
        known_keys = self.list_keys + self.dict_keys + self.extra_keys
        for n in known_keys:
            a = getattr(self, n)
            if a:
                d[n] = a
        return d 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:20,代碼來源:misc_util.py

示例2: _add_library

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def _add_library(self, name, sources, install_dir, build_info):
        """Common implementation for add_library and add_installed_library. Do
        not use directly"""
        build_info = copy.copy(build_info)
        name = name #+ '__OF__' + self.name
        build_info['sources'] = sources

        # Sometimes, depends is not set up to an empty list by default, and if
        # depends is not given to add_library, distutils barfs (#1134)
        if not 'depends' in build_info:
            build_info['depends'] = []

        self._fix_paths_dict(build_info)

        # Add to libraries list so that it is build with build_clib
        self.libraries.append((name, build_info)) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:18,代碼來源:misc_util.py

示例3: make_ext

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def make_ext(pkg_name, relpath, srcs, libraries=[], library_dirs=default_lib_dir,
             include_dirs=default_include, extra_compile_flags=[],
             extra_link_flags=[], **kwargs):
    if '/' in relpath:
        relpath = os.path.join(*relpath.split('/'))
    if (os.path.isfile(os.path.join(pyscf_lib_dir, 'build', 'CMakeCache.txt')) and
        os.path.isfile(os.path.join(pyscf_lib_dir, *pkg_name.split('.')) + so_ext)):
        return None
    else:
        if sys.platform.startswith('darwin'):
            soname = pkg_name.split('.')[-1]
            extra_link_flags = extra_link_flags + ['-install_name', '@loader_path/'+soname+so_ext]
            runtime_library_dirs = []
        elif sys.platform.startswith('aix') or sys.platform.startswith('os400'):
            extra_compile_flags = extra_compile_flags + ['-fopenmp']
            extra_link_flags = extra_link_flags + ['-lblas', '-lgomp', '-Wl,-brtl']
            runtime_library_dirs = ['$ORIGIN', '.']
        else:
            extra_compile_flags = extra_compile_flags + ['-fopenmp']
            extra_link_flags = extra_link_flags + ['-fopenmp']
            runtime_library_dirs = ['$ORIGIN', '.']
        srcs = make_src(relpath, srcs)
        return Extension(pkg_name, srcs,
                         libraries = libraries,
                         library_dirs = library_dirs,
                         include_dirs = include_dirs + [os.path.join(pyscf_lib_dir,relpath)],
                         extra_compile_args = extra_compile_flags,
                         extra_link_args = extra_link_flags,
# Be careful with the ld flag "-Wl,-R$ORIGIN" in the shell.
# When numpy.distutils is imported, the default CCompiler of distutils will be
# overwritten. Compilation is executed in shell and $ORIGIN will be converted to ''
                         runtime_library_dirs = runtime_library_dirs,
                         **kwargs) 
開發者ID:pyscf,項目名稱:pyscf,代碼行數:35,代碼來源:setup.py

示例4: get_ext_filename

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def get_ext_filename(self, ext_name):
        from distutils.sysconfig import get_config_var
        ext_path = ext_name.split('.')
        filename = build_ext.get_ext_filename(self, ext_name)
        name, ext_suffix = os.path.splitext(filename)
        return os.path.join(*ext_path) + ext_suffix 
開發者ID:pyscf,項目名稱:pyscf,代碼行數:8,代碼來源:setup.py

示例5: get_num_build_jobs

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def get_num_build_jobs():
    """
    Get number of parallel build jobs set by the --parallel command line
    argument of setup.py
    If the command did not receive a setting the environment variable
    NPY_NUM_BUILD_JOBS is checked. If that is unset, return the number of
    processors on the system, with a maximum of 8 (to prevent
    overloading the system if there a lot of CPUs).

    Returns
    -------
    out : int
        number of parallel jobs that can be run

    """
    from numpy.distutils.core import get_distribution
    try:
        cpu_count = len(os.sched_getaffinity(0))
    except AttributeError:
        cpu_count = multiprocessing.cpu_count()
    cpu_count = min(cpu_count, 8)
    envjobs = int(os.environ.get("NPY_NUM_BUILD_JOBS", cpu_count))
    dist = get_distribution()
    # may be None during configuration
    if dist is None:
        return envjobs

    # any of these three may have the job set, take the largest
    cmdattr = (getattr(dist.get_command_obj('build'), 'parallel', None),
               getattr(dist.get_command_obj('build_ext'), 'parallel', None),
               getattr(dist.get_command_obj('build_clib'), 'parallel', None))
    if all(x is None for x in cmdattr):
        return envjobs
    else:
        return max(x for x in cmdattr if x is not None) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:37,代碼來源:misc_util.py

示例6: get_distribution

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def get_distribution(self):
        """Return the distutils distribution object for self."""
        from numpy.distutils.core import get_distribution
        return get_distribution() 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:6,代碼來源:misc_util.py

示例7: _add_library

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def _add_library(self, name, sources, install_dir, build_info):
        """Common implementation for add_library and add_installed_library. Do
        not use directly"""
        build_info = copy.copy(build_info)
        build_info['sources'] = sources

        # Sometimes, depends is not set up to an empty list by default, and if
        # depends is not given to add_library, distutils barfs (#1134)
        if not 'depends' in build_info:
            build_info['depends'] = []

        self._fix_paths_dict(build_info)

        # Add to libraries list so that it is build with build_clib
        self.libraries.append((name, build_info)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:17,代碼來源:misc_util.py

示例8: get_config_cmd

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def get_config_cmd(self):
        """
        Returns the numpy.distutils config command instance.
        """
        cmd = get_cmd('config')
        cmd.ensure_finalized()
        cmd.dump_source = 0
        cmd.noisy = 0
        old_path = os.environ.get('PATH')
        if old_path:
            path = os.pathsep.join(['.', old_path])
            os.environ['PATH'] = path
        return cmd 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:15,代碼來源:misc_util.py

示例9: append_to

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def append_to(self, extlib):
        """Append libraries, include_dirs to extension or library item.
        """
        if is_sequence(extlib):
            lib_name, build_info = extlib
            dict_append(build_info,
                        libraries=self.libraries,
                        include_dirs=self.include_dirs)
        else:
            from numpy.distutils.core import Extension
            assert isinstance(extlib, Extension), repr(extlib)
            extlib.libraries.extend(self.libraries)
            extlib.include_dirs.extend(self.include_dirs) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:15,代碼來源:misc_util.py

示例10: get_cmd

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def get_cmd(cmdname, _cache={}):
    if cmdname not in _cache:
        import distutils.core
        dist = distutils.core._setup_distribution
        if dist is None:
            from distutils.errors import DistutilsInternalError
            raise DistutilsInternalError(
                  'setup distribution instance not initialized')
        cmd = dist.get_command_obj(cmdname)
        _cache[cmdname] = cmd
    return _cache[cmdname] 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:13,代碼來源:misc_util.py

示例11: get_build_architecture

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def get_build_architecture():
    # Importing distutils.msvccompiler triggers a warning on non-Windows
    # systems, so delay the import to here.
    from distutils.msvccompiler import get_build_architecture
    return get_build_architecture() 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:7,代碼來源:misc_util.py

示例12: libpaths

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def libpaths(paths, bits):
    """Return a list of library paths valid on 32 or 64 bit systems.

    Inputs:
      paths : sequence
        A sequence of strings (typically paths)
      bits : int
        An integer, the only valid values are 32 or 64.  A ValueError exception
      is raised otherwise.

    Examples:

    Consider a list of directories
    >>> paths = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']

    For a 32-bit platform, this is already valid:
    >>> np.distutils.system_info.libpaths(paths,32)
    ['/usr/X11R6/lib', '/usr/X11/lib', '/usr/lib']

    On 64 bits, we prepend the '64' postfix
    >>> np.distutils.system_info.libpaths(paths,64)
    ['/usr/X11R6/lib64', '/usr/X11R6/lib', '/usr/X11/lib64', '/usr/X11/lib',
    '/usr/lib64', '/usr/lib']
    """
    if bits not in (32, 64):
        raise ValueError("Invalid bit size in libpaths: 32 or 64 only")

    # Handle 32bit case
    if bits == 32:
        return paths

    # Handle 64bit case
    out = []
    for p in paths:
        out.extend([p + '64', p])

    return out 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:39,代碼來源:system_info.py

示例13: calc_libraries_info

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def calc_libraries_info(self):
        libs = self.get_libraries()
        dirs = self.get_lib_dirs()
        # The extensions use runtime_library_dirs
        r_dirs = self.get_runtime_lib_dirs()
        # Intrinsic distutils use rpath, we simply append both entries
        # as though they were one entry
        r_dirs.extend(self.get_runtime_lib_dirs(key='rpath'))
        info = {}
        for lib in libs:
            i = self.check_libs(dirs, [lib])
            if i is not None:
                dict_append(info, **i)
            else:
                log.info('Library %s was not found. Ignoring' % (lib))

            if r_dirs:
                i = self.check_libs(r_dirs, [lib])
                if i is not None:
                    # Swap library keywords found to runtime_library_dirs
                    # the libraries are insisting on the user having defined
                    # them using the library_dirs, and not necessarily by
                    # runtime_library_dirs
                    del i['libraries']
                    i['runtime_library_dirs'] = i.pop('library_dirs')
                    dict_append(info, **i)
                else:
                    log.info('Runtime library %s was not found. Ignoring' % (lib))

        return info 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:32,代碼來源:system_info.py

示例14: get_info

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def get_info(self, notfound_action=0):
        """ Return a dictonary with items that are compatible
            with numpy.distutils.setup keyword arguments.
        """
        flag = 0
        if not self.has_info():
            flag = 1
            log.info(self.__class__.__name__ + ':')
            if hasattr(self, 'calc_info'):
                self.calc_info()
            if notfound_action:
                if not self.has_info():
                    if notfound_action == 1:
                        warnings.warn(self.notfounderror.__doc__, stacklevel=2)
                    elif notfound_action == 2:
                        raise self.notfounderror(self.notfounderror.__doc__)
                    else:
                        raise ValueError(repr(notfound_action))

            if not self.has_info():
                log.info('  NOT AVAILABLE')
                self.set_info()
            else:
                log.info('  FOUND:')

        res = self.saved_results.get(self.__class__.__name__)
        if self.verbosity > 0 and flag:
            for k, v in res.items():
                v = str(v)
                if k in ['sources', 'libraries'] and len(v) > 270:
                    v = v[:120] + '...\n...\n...' + v[-120:]
                log.info('    %s = %s', k, v)
            log.info('')

        return copy.deepcopy(res) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:37,代碼來源:system_info.py

示例15: calc_info

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import distutils [as 別名]
def calc_info(self):
        c = customized_ccompiler()

        lib_dirs = self.get_lib_dirs()

        openblas_libs = self.get_libs('libraries', self._lib_names)
        if openblas_libs == self._lib_names: # backward compat with 1.8.0
            openblas_libs = self.get_libs('openblas_libs', self._lib_names)

        info = self.check_libs(lib_dirs, openblas_libs, [])

        if c.compiler_type == "msvc" and info is None:
            from numpy.distutils.fcompiler import new_fcompiler
            f = new_fcompiler(c_compiler=c)
            if f and f.compiler_type == 'gnu95':
                # Try gfortran-compatible library files
                info = self.check_msvc_gfortran_libs(lib_dirs, openblas_libs)
                # Skip lapack check, we'd need build_ext to do it
                assume_lapack = True
        elif info:
            assume_lapack = False
            info['language'] = 'c'

        if info is None:
            return

        # Add extra info for OpenBLAS
        extra_info = self.calc_extra_info()
        dict_append(info, **extra_info)

        if not (assume_lapack or self.check_embedded_lapack(info)):
            return

        info['define_macros'] = [('HAVE_CBLAS', None)]
        self.set_info(**info) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:37,代碼來源:system_info.py


注:本文中的numpy.distutils方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。