当前位置: 首页>>代码示例>>Python>>正文


Python sysconfig.get_paths函数代码示例

本文整理汇总了Python中sysconfig.get_paths函数的典型用法代码示例。如果您正苦于以下问题:Python get_paths函数的具体用法?Python get_paths怎么用?Python get_paths使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_paths函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_dirs

def get_dirs(user=True):
    """Get the 'scripts' and 'purelib' directories we'll install into.

    This is now a thin wrapper around sysconfig.get_paths(). It's not inlined,
    because some tests mock it out to install to a different location.
    """
    if user:
        if (sys.platform == "darwin") and sysconfig.get_config_var('PYTHONFRAMEWORK'):
            return sysconfig.get_paths('osx_framework_user')
        return sysconfig.get_paths(os.name + '_user')
    else:
        # The default scheme is 'posix_prefix' or 'nt', and should work for e.g.
        # installing into a virtualenv
        return sysconfig.get_paths()
开发者ID:blink1073,项目名称:flit,代码行数:14,代码来源:install.py

示例2: test_get_paths

 def test_get_paths(self):
     scheme = get_paths()
     default_scheme = _get_default_scheme()
     wanted = _expand_vars(default_scheme, None)
     wanted = sorted(wanted.items())
     scheme = sorted(scheme.items())
     self.assertEqual(scheme, wanted)
开发者ID:chidea,项目名称:GoPythonDLLWrapper,代码行数:7,代码来源:test_sysconfig.py

示例3: __enter__

    def __enter__(self):
        self._temp_dir.create()

        self.save_path = os.environ.get('PATH', None)
        self.save_pythonpath = os.environ.get('PYTHONPATH', None)

        install_scheme = 'nt' if (os.name == 'nt') else 'posix_prefix'
        install_dirs = get_paths(install_scheme, vars={
            'base': self._temp_dir.path,
            'platbase': self._temp_dir.path,
        })

        scripts = install_dirs['scripts']
        if self.save_path:
            os.environ['PATH'] = scripts + os.pathsep + self.save_path
        else:
            os.environ['PATH'] = scripts + os.pathsep + os.defpath

        if install_dirs['purelib'] == install_dirs['platlib']:
            lib_dirs = install_dirs['purelib']
        else:
            lib_dirs = install_dirs['purelib'] + os.pathsep + \
                install_dirs['platlib']
        if self.save_pythonpath:
            os.environ['PYTHONPATH'] = lib_dirs + os.pathsep + \
                self.save_pythonpath
        else:
            os.environ['PYTHONPATH'] = lib_dirs

        return self._temp_dir.path
开发者ID:mwilliamson,项目名称:pip,代码行数:30,代码来源:wheel.py

示例4: _find_config

def _find_config():
    # prefer config file in the following order:
    # 1) current directory, 2) user home directory, 3) bundled config
    config_dirs = (
        ['.'] + [appdirs.user_config_dir("bandit")] +
        appdirs.site_config_dir("bandit", multipath=True).split(':'))
    if _running_under_virtualenv():
        config_dirs.append(os.path.join(sys.prefix, 'etc', 'bandit'))
        config_dirs.append(
            os.path.join(sysconfig.get_paths().get('purelib', ''),
                         'bandit', 'config'))
    config_locations = [os.path.join(s, BASE_CONFIG) for s in config_dirs]

    # pip on Mac installs to the following path, but appdirs expects to
    # follow Mac's BPFileSystem spec which doesn't include this path so
    # we'll insert it. Issue raised as http://git.io/vOreU
    mac_pip_cfg_path = "/usr/local/etc/bandit/bandit.yaml"
    if mac_pip_cfg_path not in config_locations:
        config_locations.append(mac_pip_cfg_path)

    for config_file in config_locations:
        if os.path.isfile(config_file):
            return config_file  # Found a valid config
    else:
        # Failed to find any config, raise an error.
        raise utils.NoConfigFileFound(config_locations)
开发者ID:SalemAmeen,项目名称:bandit,代码行数:26,代码来源:bandit.py

示例5: __enter__

    def __enter__(self):
        self.path = mkdtemp(prefix='pep517-build-env-')
        log.info('Temporary build environment: %s', self.path)

        self.save_path = os.environ.get('PATH', None)
        self.save_pythonpath = os.environ.get('PYTHONPATH', None)

        install_scheme = 'nt' if (os.name == 'nt') else 'posix_prefix'
        install_dirs = get_paths(install_scheme, vars={
            'base': self.path,
            'platbase': self.path,
        })

        scripts = install_dirs['scripts']
        if self.save_path:
            os.environ['PATH'] = scripts + os.pathsep + self.save_path
        else:
            os.environ['PATH'] = scripts + os.pathsep + os.defpath

        if install_dirs['purelib'] == install_dirs['platlib']:
            lib_dirs = install_dirs['purelib']
        else:
            lib_dirs = install_dirs['purelib'] + os.pathsep + \
                install_dirs['platlib']
        if self.save_pythonpath:
            os.environ['PYTHONPATH'] = lib_dirs + os.pathsep + \
                self.save_pythonpath
        else:
            os.environ['PYTHONPATH'] = lib_dirs

        return self
开发者ID:2216288075,项目名称:meiduo_project,代码行数:31,代码来源:envbuild.py

示例6: __enter__

    def __enter__(self):
        self.save_path = os.environ.get('PATH', None)
        self.save_pythonpath = os.environ.get('PYTHONPATH', None)
        self.save_nousersite = os.environ.get('PYTHONNOUSERSITE', None)

        install_scheme = 'nt' if (os.name == 'nt') else 'posix_prefix'
        install_dirs = get_paths(install_scheme, vars={
            'base': self.path,
            'platbase': self.path,
        })

        scripts = install_dirs['scripts']
        if self.save_path:
            os.environ['PATH'] = scripts + os.pathsep + self.save_path
        else:
            os.environ['PATH'] = scripts + os.pathsep + os.defpath

        # Note: prefer distutils' sysconfig to get the
        # library paths so PyPy is correctly supported.
        purelib = get_python_lib(plat_specific=0, prefix=self.path)
        platlib = get_python_lib(plat_specific=1, prefix=self.path)
        if purelib == platlib:
            lib_dirs = purelib
        else:
            lib_dirs = purelib + os.pathsep + platlib
        if self.save_pythonpath:
            os.environ['PYTHONPATH'] = lib_dirs + os.pathsep + \
                self.save_pythonpath
        else:
            os.environ['PYTHONPATH'] = lib_dirs

        os.environ['PYTHONNOUSERSITE'] = '1'

        return self.path
开发者ID:Black-Thunder01,项目名称:PythonAPI,代码行数:34,代码来源:build_env.py

示例7: _write_ninja_file

def _write_ninja_file(path, name, sources, extra_cflags, extra_ldflags,
                      extra_include_paths):
    # Version 1.3 is required for the `deps` directive.
    config = ['ninja_required_version = 1.3']
    config.append('cxx = {}'.format(os.environ.get('CXX', 'c++')))

    # Turn into absolute paths so we can emit them into the ninja build
    # file wherever it is.
    sources = [os.path.abspath(file) for file in sources]
    includes = [os.path.abspath(file) for file in extra_include_paths]

    # include_paths() gives us the location of torch/torch.h
    includes += include_paths()
    # sysconfig.get_paths()['include'] gives us the location of Python.h
    includes.append(sysconfig.get_paths()['include'])

    cflags = ['-fPIC', '-std=c++11']
    cflags += ['-I{}'.format(include) for include in includes]
    cflags += extra_cflags
    flags = ['cflags = {}'.format(' '.join(cflags))]

    ldflags = ['-shared'] + extra_ldflags
    # The darwin linker needs explicit consent to ignore unresolved symbols
    if sys.platform == 'darwin':
        ldflags.append('-undefined dynamic_lookup')
    flags.append('ldflags = {}'.format(' '.join(ldflags)))

    # See https://ninja-build.org/build.ninja.html for reference.
    compile_rule = ['rule compile']
    compile_rule.append(
        '  command = $cxx -MMD -MF $out.d $cflags -c $in -o $out')
    compile_rule.append('  depfile = $out.d')
    compile_rule.append('  deps = gcc')
    compile_rule.append('')

    link_rule = ['rule link']
    link_rule.append('  command = $cxx $ldflags $in -o $out')

    # Emit one build rule per source to enable incremental build.
    object_files = []
    build = []
    for source_file in sources:
        # '/path/to/file.cpp' -> 'file'
        file_name = os.path.splitext(os.path.basename(source_file))[0]
        target = '{}.o'.format(file_name)
        object_files.append(target)
        build.append('build {}: compile {}'.format(target, source_file))

    library_target = '{}.so'.format(name)
    link = ['build {}: link {}'.format(library_target, ' '.join(object_files))]

    default = ['default {}'.format(library_target)]

    # 'Blocks' should be separated by newlines, for visual benefit.
    blocks = [config, flags, compile_rule, link_rule, build, link, default]
    with open(path, 'w') as build_file:
        for block in blocks:
            lines = '\n'.join(block)
            build_file.write('{}\n\n'.format(lines))
开发者ID:bhuWenDongchao,项目名称:pytorch,代码行数:59,代码来源:cpp_extension.py

示例8: expand_categories

 def expand_categories(self, path_with_categories):
     local_vars = get_paths()
     local_vars['distribution.name'] = self.distribution.metadata['Name']
     expanded_path = format_value(path_with_categories, local_vars)
     expanded_path = format_value(expanded_path, local_vars)
     if '{' in expanded_path and '}' in expanded_path:
         logger.warning(
             '%s: unable to expand %s, some categories may be missing',
             self.get_command_name(), path_with_categories)
     return expanded_path
开发者ID:MrMalina,项目名称:Source.Python,代码行数:10,代码来源:install_data.py

示例9: get_stdlib_path

def get_stdlib_path():
    """Returns the path to the standard lib for the current path installation.

    This function can be dropped and "sysconfig.get_paths()" used directly once Python 2.6 support is dropped.
    """
    if sys.version_info >= (2, 7):
        import sysconfig
        return sysconfig.get_paths()['stdlib']
    else:
        return os.path.join(sys.prefix, 'lib')
开发者ID:Elizaveta239,项目名称:PyDev.Debugger,代码行数:10,代码来源:isort.py

示例10: get_context

 def get_context(self):
     ret = {}
     try:
         ret['sysconfig'] = sysconfig.get_config_vars()
     except:
         pass
     try:
         ret['paths'] = sysconfig.get_paths()
     except:
         pass
     return ret
开发者ID:Kewpie007,项目名称:clastic,代码行数:11,代码来源:meta.py

示例11: select_scheme

 def select_scheme(self, name):
     """Set the install directories by applying the install schemes."""
     # it's the caller's problem if they supply a bad name!
     scheme = get_paths(name, expand=False)
     for key, value in scheme.items():
         if key == 'platinclude':
             key = 'headers'
             value = os.path.join(value, self.distribution.metadata['Name'])
         attrname = 'install_' + key
         if hasattr(self, attrname):
             if getattr(self, attrname) is None:
                 setattr(self, attrname, value)
开发者ID:MrMalina,项目名称:Source.Python,代码行数:12,代码来源:install_dist.py

示例12: __init__

 def __init__(self, path):
     # type: (str) -> None
     self.path = path
     self.setup = False
     self.bin_dir = get_paths(
         'nt' if os.name == 'nt' else 'posix_prefix',
         vars={'base': path, 'platbase': path}
     )['scripts']
     # Note: prefer distutils' sysconfig to get the
     # library paths so PyPy is correctly supported.
     purelib = get_python_lib(plat_specific=False, prefix=path)
     platlib = get_python_lib(plat_specific=True, prefix=path)
     if purelib == platlib:
         self.lib_dirs = [purelib]
     else:
         self.lib_dirs = [purelib, platlib]
开发者ID:mkurnikov,项目名称:pip,代码行数:16,代码来源:build_env.py

示例13: __init__

    def __init__(self, config, sections):
        super(PathFinder, self).__init__(config, sections)

        # restore the original import path (i.e. not the path to bin/isort)
        self.paths = [os.getcwd()]

        # virtual env
        self.virtual_env = self.config.get('virtual_env') or os.environ.get('VIRTUAL_ENV')
        if self.virtual_env:
            self.virtual_env = os.path.realpath(self.virtual_env)
        self.virtual_env_src = False
        if self.virtual_env:
            self.virtual_env_src = '{0}/src/'.format(self.virtual_env)
            for path in glob('{0}/lib/python*/site-packages'.format(self.virtual_env)):
                if path not in self.paths:
                    self.paths.append(path)
            for path in glob('{0}/lib/python*/*/site-packages'.format(self.virtual_env)):
                if path not in self.paths:
                    self.paths.append(path)
            for path in glob('{0}/src/*'.format(self.virtual_env)):
                if os.path.isdir(path):
                    self.paths.append(path)

        # conda
        self.conda_env = self.config.get('conda_env') or os.environ.get('CONDA_PREFIX')
        if self.conda_env:
            self.conda_env = os.path.realpath(self.conda_env)
            for path in glob('{0}/lib/python*/site-packages'.format(self.conda_env)):
                if path not in self.paths:
                    self.paths.append(path)
            for path in glob('{0}/lib/python*/*/site-packages'.format(self.conda_env)):
                if path not in self.paths:
                    self.paths.append(path)

        # handle case-insensitive paths on windows
        self.stdlib_lib_prefix = os.path.normcase(sysconfig.get_paths()['stdlib'])
        if self.stdlib_lib_prefix not in self.paths:
            self.paths.append(self.stdlib_lib_prefix)

        # handle compiled libraries
        self.ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") or ".so"

        # add system paths
        for path in sys.path[1:]:
            if path not in self.paths:
                self.paths.append(path)
开发者ID:timothycrosley,项目名称:isort,代码行数:46,代码来源:finders.py

示例14: CopyPythonLibs

def CopyPythonLibs(dst, overwrite_lib, report=print):
    import sysconfig
    src = sysconfig.get_paths()['platstdlib']
    # Unix 'platstdlib' excludes 'lib', eg:
    #  '/usr/lib/python3.3' vs 'C:\blender\bin\2.58\python\Lib'
    # in both cases we have to end up with './2.58/python/lib'
    if sys.platform[:3] != "win":
        dst = os.path.join(dst, os.path.basename(src))

    if os.path.exists(src):
        write = False
        if os.path.exists(dst):
            if overwrite_lib:
                shutil.rmtree(dst)
                write = True
        else:
            write = True
        if write:
            shutil.copytree(src, dst, ignore=lambda dir, contents: [i for i in contents if i == '__pycache__'])
    else:
        report({'WARNING'}, "Python not found in %r, skipping pythn copy." % src)
开发者ID:MakersF,项目名称:BlenderDev,代码行数:21,代码来源:game_engine_save_as_runtime.py

示例15: get_include_dir

def get_include_dir():
    """Returns the path to the Python environment's include dir."""
    return get_paths()['include']
开发者ID:ClinicalGraphics,项目名称:pyopcode,代码行数:3,代码来源:setup_utils.py


注:本文中的sysconfig.get_paths函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。