本文整理汇总了Python中sysconfig.get_paths函数的典型用法代码示例。如果您正苦于以下问题:Python get_paths函数的具体用法?Python get_paths怎么用?Python get_paths使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_paths函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: setup
def setup(**attrs):
"""Mock the setup(**attrs) in order to retrive metadata."""
# use the distutils v1 processings to correctly parse metadata.
#XXX we could also use the setuptools distibution ???
from distutils.dist import Distribution
dist = Distribution(attrs)
dist.parse_config_files()
# 1. retrieves metadata that are quite similar PEP314<->PEP345
labels = (('name',) * 2,
('version',) * 2,
('author',) * 2,
('author_email',) * 2,
('maintainer',) * 2,
('maintainer_email',) * 2,
('description', 'summary'),
('long_description', 'description'),
('url', 'home_page'),
('platforms', 'platform'))
if sys.version[:3] >= '2.5':
labels += (('provides', 'provides-dist'),
('obsoletes', 'obsoletes-dist'),
('requires', 'requires-dist'),)
get = lambda lab: getattr(dist.metadata, lab.replace('-', '_'))
data.update((new, get(old)) for (old, new) in labels if get(old))
# 2. retrieves data that requires special processings.
data['classifier'].update(dist.get_classifiers() or [])
data['scripts'].extend(dist.scripts or [])
data['packages'].extend(dist.packages or [])
data['modules'].extend(dist.py_modules or [])
# 2.1 data_files -> resources.
if dist.data_files:
if len(dist.data_files) < 2 or \
isinstance(dist.data_files[1], str):
dist.data_files = [('', dist.data_files)]
# add tokens in the destination paths
vars = {'distribution.name': data['name']}
path_tokens = sysconfig.get_paths(vars=vars).items()
# sort tokens to use the longest one first
# TODO chain two sorted with key arguments, remove cmp
path_tokens.sort(cmp=lambda x, y: cmp(len(y), len(x)),
key=lambda x: x[1])
for dest, srcs in (dist.data_files or []):
dest = os.path.join(sys.prefix, dest)
for tok, path in path_tokens:
if dest.startswith(path):
dest = ('{%s}' % tok) + dest[len(path):]
files = [('/ '.join(src.rsplit('/', 1)), dest)
for src in srcs]
data['resources'].extend(files)
continue
# 2.2 package_data -> extra_files
package_dirs = dist.package_dir or {}
for package, extras in dist.package_data.iteritems() or []:
package_dir = package_dirs.get(package, package)
files = [os.path.join(package_dir, f) for f in extras]
data['extra_files'].extend(files)
# Use README file if its content is the desciption
if "description" in data:
ref = md5(re.sub('\s', '', self.data['description']).lower())
ref = ref.digest()
for readme in glob.glob('README*'):
fp = open(readme)
try:
contents = fp.read()
finally:
fp.close()
val = md5(re.sub('\s', '', contents.lower())).digest()
if val == ref:
del data['description']
data['description-file'] = readme
break
开发者ID:pombredanne,项目名称:vanity_app,代码行数:73,代码来源:mkcfg.py
示例17: symengine_h_get_include
def symengine_h_get_include():
if sys.platform == 'win32':
# Strictly only valid for recent conda installations
return os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(symengine.__file__)))), 'Library', 'include')
else:
return os.path.dirname(get_paths()['include'])
开发者ID:pycalphad,项目名称:pycalphad,代码行数:6,代码来源:setup.py
示例18: pkgconfig
gst_flags = {
'extra_link_args': [
'-F/Library/Frameworks',
'-Xlinker', '-rpath',
'-Xlinker', '/Library/Frameworks',
'-Xlinker', '-headerpad',
'-Xlinker', '190',
'-framework', 'GStreamer'],
'include_dirs': [join(f_path, 'Headers')]}
elif platform == 'win32':
gst_flags = pkgconfig('gstreamer-1.0')
if 'libraries' in gst_flags:
print('GStreamer found via pkg-config')
gstreamer_valid = True
c_options['use_gstreamer'] = True
elif exists(join(get_paths()['include'], 'gst', 'gst.h')):
print('GStreamer found via gst.h')
gstreamer_valid = True
c_options['use_gstreamer'] = True
gst_flags = {
'libraries': ['gstreamer-1.0', 'glib-2.0', 'gobject-2.0']}
if not gstreamer_valid:
# use pkg-config approach instead
gst_flags = pkgconfig('gstreamer-1.0')
if 'libraries' in gst_flags:
print('GStreamer found via pkg-config')
c_options['use_gstreamer'] = True
# detect SDL2, only on desktop and iOS, or android if explicitly enabled
开发者ID:kivy,项目名称:kivy,代码行数:31,代码来源:setup.py
示例19:
import cPickle, os, sys
import logging
import fnmatch
import platform
import sysconfig
from Cython.Build import cythonize
REQUIRES = ['dpkt', 'Cython', 'setuptools']
SOURCE_FILES = ['pcap.pyx', 'pcap_ex.c']
WIN_SDK_PATH = os.environ.get('WindowsSdkDir', None)
VCINSTALLDIR = os.environ.get('VCINSTALLDIR', None)
# Header Files
INC_WPCAP = r'C:\wpdpack\Include'
INC_PYTHON = sysconfig.get_paths().get('include', None)
INC_WINSDK = os.path.join(WIN_SDK_PATH,'Include') if WIN_SDK_PATH else None
INC_MSVC = os.path.join(VCINSTALLDIR, r'include') if VCINSTALLDIR else None
INCLUDE_PATHS = [INC_WPCAP, INC_PYTHON, INC_WINSDK, INC_MSVC]
# Libraries
LIB_WPACP = r'C:\wpdpack\Lib\x64'
LIB_PYTHON = r'C:\Anaconda3\envs\py2.7\libs'
LIBRARIES = ['wpcap', 'iphlpapi']
EXTRA_COMPILE_ARGS = [ '-DWIN32', '-DWPCAP' ,'-D_CRT_SECURE_NO_WARNINGS']
DEFINE_MACROS = []
#DEFINE_MACROS += [('HAVE_PCAP_INT_H', 0)]
DEFINE_MACROS += [('HAVE_PCAP_FILE', 1)]
开发者ID:stkyle,项目名称:winpcap,代码行数:31,代码来源:setup.py
示例20: Copyright
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2010 Doug Hellmann. All rights reserved.
#
"""The paths for a scheme.
"""
#end_pymotw_header
import sysconfig
import pprint
import os
for scheme in ['posix_prefix', 'posix_user']:
print scheme
print '=' * len(scheme)
paths = sysconfig.get_paths(scheme=scheme)
prefix = os.path.commonprefix(paths.values())
print 'prefix = %s\n' % prefix
for name, path in sorted(paths.items()):
print '%s\n .%s' % (name, path[len(prefix):])
print
开发者ID:artivee,项目名称:basc,代码行数:22,代码来源:sysconfig_get_paths.py
注:本文中的sysconfig.get_paths函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论