本文整理汇总了Python中sysconfig.get_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_path函数的具体用法?Python get_path怎么用?Python get_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _find_libpy3_windows
def _find_libpy3_windows(self, env):
'''
Find python3 libraries on Windows and also verify that the arch matches
what we are building for.
'''
pyarch = sysconfig.get_platform()
arch = detect_cpu_family(env.coredata.compilers)
if arch == 'x86':
arch = '32'
elif arch == 'x86_64':
arch = '64'
else:
# We can't cross-compile Python 3 dependencies on Windows yet
mlog.log('Unknown architecture {!r} for'.format(arch),
mlog.bold(self.name))
self.is_found = False
return
# Pyarch ends in '32' or '64'
if arch != pyarch[-2:]:
mlog.log('Need', mlog.bold(self.name),
'for {}-bit, but found {}-bit'.format(arch, pyarch[-2:]))
self.is_found = False
return
inc = sysconfig.get_path('include')
platinc = sysconfig.get_path('platinclude')
self.compile_args = ['-I' + inc]
if inc != platinc:
self.compile_args.append('-I' + platinc)
# Nothing exposes this directly that I coulf find
basedir = sysconfig.get_config_var('base')
vernum = sysconfig.get_config_var('py_version_nodot')
self.link_args = ['-L{}/libs'.format(basedir),
'-lpython{}'.format(vernum)]
self.version = sysconfig.get_config_var('py_version_short')
self.is_found = True
开发者ID:pombredanne,项目名称:meson,代码行数:35,代码来源:misc.py
示例2: print_includes
def print_includes():
dirs = [sysconfig.get_path('include')]
if sysconfig.get_path('platinclude') not in dirs:
dirs.append(sysconfig.get_path('platinclude'))
if get_include() not in dirs:
dirs.append(get_include())
print(' '.join('-I' + d for d in dirs))
开发者ID:Polymedia,项目名称:xlnt,代码行数:7,代码来源:__main__.py
示例3: getusersitepackages
def getusersitepackages():
"""Returns the user-specific site-packages directory path.
If the global variable ``USER_SITE`` is not initialized yet, this
function will also set it.
"""
global USER_SITE
user_base = getuserbase() # this will also set USER_BASE
if USER_SITE is not None:
return USER_SITE
from sysconfig import get_path
if sys.platform == 'darwin':
from sysconfig import get_config_var
if get_config_var('PYTHONFRAMEWORK'):
USER_SITE = get_path('purelib', 'osx_framework_user')
return USER_SITE
if sys.platform == 'win32':
from sysconfig import _POSIX_BUILD
if _POSIX_BUILD:
USER_SITE = get_path('purelib', 'posix_user')
return USER_SITE
USER_SITE = get_path('purelib', '%s_user' % os.name)
return USER_SITE
开发者ID:OpenModelica,项目名称:OMDev,代码行数:28,代码来源:site.py
示例4: test_user_similar
def test_user_similar(self):
# Issue 8759 : make sure the posix scheme for the users
# is similar to the global posix_prefix one
base = get_config_var("base")
user = get_config_var("userbase")
for name in ("stdlib", "platstdlib", "purelib", "platlib"):
global_path = get_path(name, "posix_prefix")
user_path = get_path(name, "posix_user")
self.assertEquals(user_path, global_path.replace(base, user))
开发者ID:ksenor,项目名称:spy,代码行数:9,代码来源:test_sysconfig.py
示例5: test_user_similar
def test_user_similar(self):
# Issue 8759 : make sure the posix scheme for the users
# is similar to the global posix_prefix one
base = get_config_var('base')
user = get_config_var('userbase')
for name in ('stdlib', 'platstdlib', 'purelib', 'platlib'):
global_path = get_path(name, 'posix_prefix')
user_path = get_path(name, 'posix_user')
self.assertEqual(user_path, global_path.replace(base, user))
开发者ID:Arcenciel,项目名称:DDReader,代码行数:9,代码来源:test_sysconfig.py
示例6: get_sys_path
def get_sys_path(location, name):
# Returns the sysconfig path for a distribution, or None
for scheme in sysconfig.get_scheme_names():
for path_type in ["platlib", "purelib"]:
path = sysconfig.get_path(path_type, scheme)
try:
if samefile(path, location):
return sysconfig.get_path(name, scheme)
except EnvironmentError:
pass
开发者ID:GNOME,项目名称:pygobject,代码行数:10,代码来源:setup.py
示例7: getusersitepackages
def getusersitepackages():
global USER_SITE
user_base = getuserbase()
if USER_SITE is not None:
return USER_SITE
from sysconfig import get_path
if sys.platform == 'darwin':
from sysconfig import get_config_var
if get_config_var('PYTHONFRAMEWORK'):
USER_SITE = get_path('purelib', 'osx_framework_user')
return USER_SITE
USER_SITE = get_path('purelib', '%s_user' % os.name)
return USER_SITE
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:13,代码来源:site.py
示例8: print_includes
def print_includes():
dirs = [sysconfig.get_path('include'),
sysconfig.get_path('platinclude'),
get_include(),
get_include(True)]
# Make unique but preserve order
unique_dirs = []
for d in dirs:
if d not in unique_dirs:
unique_dirs.append(d)
print(' '.join('-I' + d for d in unique_dirs))
开发者ID:Bella42,项目名称:ADIOS2,代码行数:13,代码来源:__main__.py
示例9: sysconfig2
def sysconfig2():
# import sysconfig module - Provide access to Python’s configuration information
import sysconfig
# returns an installation path corresponding to the path name
print("Path Name : ", sysconfig.get_path("stdlib"))
print()
# returns a string that identifies the current platform.
print("Current Platform : ", sysconfig.get_platform())
print()
# returns the MAJOR.MINOR Python version number as a string
print("Python Version Number : ", sysconfig.get_python_version())
print()
# returns a tuple containing all path names
print("Path Names : ", sysconfig.get_path_names())
print()
# returns a tuple containing all schemes
print("Scheme Names : ", sysconfig.get_scheme_names())
print()
# returns the value of a single variable name.
print("Variable name LIBDIR : ", sysconfig.get_config_var('LIBDIR'))
# returns the value of a single variable name.
print("Variable name LIBDEST : ", sysconfig.get_config_var('LIBDEST'))
开发者ID:mcclayac,项目名称:LearnSmart1,代码行数:29,代码来源:sysconfigExample.py
示例10: create_build_env
def create_build_env(dirname='virtualenv'):
# Create virtualenv.
if not os.path.exists(dirname):
check_call(['virtualenv', dirname])
import sysconfig
scripts_dir = os.path.basename(sysconfig.get_path('scripts'))
activate_this_file = os.path.join(dirname, scripts_dir, 'activate_this.py')
with open(activate_this_file) as f:
exec(f.read(), dict(__file__=activate_this_file))
# Import get_distribution after activating virtualenv to get info about
# the correct packages.
from pkg_resources import get_distribution, DistributionNotFound
# Upgrade pip because installation of sphinx with pip 1.1 available on Travis
# is broken (see #207) and it doesn't support the show command.
pip_version = get_distribution('pip').version
if LooseVersion(pip_version) < LooseVersion('1.5.4'):
print("Updating pip")
check_call(['pip', 'install', '--upgrade', 'pip'])
# Upgrade distribute because installation of sphinx with distribute 0.6.24
# available on Travis is broken (see #207).
try:
distribute_version = get_distribution('distribute').version
if LooseVersion(distribute_version) <= LooseVersion('0.6.24'):
print("Updating distribute")
check_call(['pip', 'install', '--upgrade', 'distribute'])
except DistributionNotFound:
pass
# Install Sphinx and Breathe.
pip_install('sphinx-doc/sphinx', '12b83372ac9316e8cbe86e7fed889296a4cc29ee',
min_version='1.4.1.dev20160531')
pip_install('michaeljones/breathe',
'6b1c5bb7a1866f15fc328b8716258354b10c1daa',
min_version='4.2.0')
开发者ID:ukaiser,项目名称:cpp-elmish,代码行数:33,代码来源:build.py
示例11: get_library_location
def get_library_location(package):
# get abs path of a package in the library, rather than locally
library_package_paths = glob(os.path.join(get_path('platlib'), '*'))
sys.path = library_package_paths + sys.path
package_path = os.path.dirname(get_loader(package).get_filename())
sys.path = sys.path[len(library_package_paths):]
return package_path
开发者ID:gsarma,项目名称:PyOpenWorm,代码行数:7,代码来源:post_install.py
示例12: find_queries_path
def find_queries_path():
possible_paths = []
# Try all possible schemes where python expects data to stay.
for scheme in sysconfig.get_scheme_names():
default_path = sysconfig.get_path(name='data', scheme=scheme)
possible_paths.append(os.path.join(default_path, 'tract_querier', 'queries'))
# Try to manage Virtual Environments on some OSes,
# where data is not put the 'local' subdirectory,
# but at the root of the virtual environment.
if default_path.endswith('local'):
possible_paths.append(os.path.join(default_path.rsplit('local', 1)[0],
'tract_querier', 'queries'))
# Case where the Tract_querier is cloned from git and simply
# added to the python path, without installation.
possible_paths.append(os.path.abspath(os.path.join(
os.path.dirname(__file__), 'data')))
paths_found = [path for path in possible_paths if os.path.exists(path)]
if not paths_found:
raise Exception('Default path for queries not found')
return paths_found[0]
开发者ID:demianw,项目名称:tract_querier,代码行数:25,代码来源:__init__.py
示例13: setup
def setup(version=None, packages=None, after_install=None, scripts=None, install_requires=None, **kwargs):
for k, v in DEFAULT.items():
kwargs.setdefault(k, v)
if not packages:
# 自动搜索包
packages = setuptools.find_packages(exclude=("testing", "scripts"))
if not version:
# 自动获取版本
version = str(Ver.read_file())
if not install_requires: # 从repuires.txt 中获取依赖包
install_requires = _get_requires()
if not scripts:
scripts = [str(path) for path in Path(".").glob("scripts/*")]
# 安装程序
dist = distutils.core.setup(
scripts=scripts, packages=packages, install_requires=install_requires, version=version, **kwargs
)
# 处理脚本
if "install" in dist.have_run and os.name == "posix" and scripts:
from sysconfig import get_path
prefix = Path(get_path("scripts"))
for script in scripts:
script_name = prefix / (Path(script).name)
if script_name.lsuffix in [".py", ".pyw"] and script_name.exists():
script_name.replace(script_name.with_suffix(""))
if "install" in dist.have_run and after_install:
after_install(dist)
开发者ID:huangtao-sh,项目名称:orange,代码行数:29,代码来源:deploy.py
示例14: find_executable
def find_executable(executable, include_others=True):
# backwards compatibility
global dir_paths
if include_others:
from ..utils import sys_prefix_unfollowed
prefixes = [sys_prefix_unfollowed()]
if sys.prefix != prefixes[0]:
prefixes.append(sys.prefix)
dir_paths = [join(p, basename(sysconfig.get_path('scripts')))
for p in prefixes]
# Is this still needed?
if on_win:
dir_paths.append('C:\\cygwin\\bin')
else:
dir_paths = []
dir_paths.extend(os.environ[str('PATH')].split(os.pathsep))
for dir_path in dir_paths:
if on_win:
for ext in ('.exe', '.bat', ''):
path = join(dir_path, executable + ext)
if isfile(path):
return path
else:
path = join(dir_path, executable)
if isfile(expanduser(path)):
return expanduser(path)
return None
开发者ID:alanhdu,项目名称:conda,代码行数:30,代码来源:find_commands.py
示例15: get_build_cflags
def get_build_cflags():
"""Synthesize a CFLAGS env var from the current python env for building of C modules."""
return '{} {} -I{}'.format(
sysconfig.get_config_var('BASECFLAGS'),
sysconfig.get_config_var('OPT'),
sysconfig.get_path('include')
)
开发者ID:pombredanne,项目名称:pants,代码行数:7,代码来源:native.py
示例16: test_user_similar
def test_user_similar(self):
# Issue #8759: make sure the posix scheme for the users
# is similar to the global posix_prefix one
base = get_config_var('base')
user = get_config_var('userbase')
# the global scheme mirrors the distinction between prefix and
# exec-prefix but not the user scheme, so we have to adapt the paths
# before comparing (issue #9100)
adapt = sys.prefix != sys.exec_prefix
for name in ('stdlib', 'platstdlib', 'purelib', 'platlib'):
global_path = get_path(name, 'posix_prefix')
if adapt:
global_path = global_path.replace(sys.exec_prefix, sys.prefix)
base = base.replace(sys.exec_prefix, sys.prefix)
user_path = get_path(name, 'posix_user')
self.assertEqual(user_path, global_path.replace(base, user, 1))
开发者ID:ArneBab,项目名称:pypyjs,代码行数:16,代码来源:test_sysconfig.py
示例17: get_install_data_dir
def get_install_data_dir(inst):
"""
:param inst: installation option
:type inst: dict
:return: the prefix where to install data
:rtype: string
"""
if 'VIRTUAL_ENV' in os.environ:
inst['prefix'] = ('environment', os.environ['VIRTUAL_ENV'])
elif 'user' in inst:
import site
inst['prefix'] = ('command line', site.USER_BASE)
elif 'root' in inst:
inst['prefix'] = ('command line',
os.path.join(inst['root'][1],
sysconfig.get_path('data').strip(os.path.sep)
)
)
if 'install_data' in inst:
install_dir = inst['install_data'][1]
elif 'prefix' in inst:
install_dir = os.path.join(inst['prefix'][1], 'share')
else:
try:
from pip.locations import distutils_scheme
except ImportError:
# from pip >=10 distutils_scheme has move into _internal package.
# It's ugly but I haven't other choice
# because the asshole Debian/Ubuntu patch pip to install in /usr/local
# but not python. So when use sysconfig.get_paths['data'] it return '/usr'
from pip._internal.locations import distutils_scheme
install_dir = os.path.join(distutils_scheme('')['data'], 'share')
return install_dir
开发者ID:gem-pasteur,项目名称:Integron_Finder,代码行数:34,代码来源:setup.py
示例18: run
def run(self):
# run default setup procedure
bdist_egg.run(self)
import sys
# Check whether setup.py is run from inside a virtualenv and get the
# appropriate install location for exploitable.py.
if hasattr(sys, 'real_prefix'):
# Inside virtualenv:
# Use Python standard library location.
from distutils.sysconfig import get_python_lib
install_base_path = get_python_lib()
else:
# Not inside virtualenv, operating on a real Python environment:
# Use location for Python site-specific, platform-specific files.
from sysconfig import get_path
install_base_path = get_path('platlib')
path_to_exploitable = os.path.join(install_base_path,
os.path.basename(self.egg_output),
'exploitable',
'exploitable.py')
print('\x1b[0;32m**********************************************')
print(' Install complete! Source exploitable.py from')
print(' your .gdbinit to make it available in GDB:')
print('')
print(' \x1b[1;37mecho \"source %s\" >> ~/.gdbinit\x1b[0;32m' % path_to_exploitable)
print('**********************************************\x1b[0m')
开发者ID:HackerTool,项目名称:exploitable,代码行数:29,代码来源:setup.py
示例19: create_build_env
def create_build_env():
# Create virtualenv.
virtualenv_dir = 'virtualenv'
check_call(['virtualenv', virtualenv_dir])
import sysconfig
scripts_dir = os.path.basename(sysconfig.get_path('scripts'))
activate_this_file = os.path.join(virtualenv_dir, scripts_dir,
'activate_this.py')
with open(activate_this_file) as f:
exec(f.read(), dict(__file__=activate_this_file))
# Upgrade pip because installation of sphinx with pip 1.1 available on Travis
# is broken (see #207) and it doesn't support the show command.
from pkg_resources import get_distribution, DistributionNotFound
pip_version = get_distribution('pip').version
if LooseVersion(pip_version) < LooseVersion('1.5.4'):
print("Updating pip")
check_call(['pip', 'install', '--upgrade', 'pip'])
# Upgrade distribute because installation of sphinx with distribute 0.6.24
# available on Travis is broken (see #207).
try:
distribute_version = get_distribution('distribute').version
if LooseVersion(distribute_version) <= LooseVersion('0.6.24'):
print("Updating distribute")
check_call(['pip', 'install', '--upgrade', 'distribute'])
except DistributionNotFound:
pass
# Install Sphinx and Breathe.
pip_install('fmtlib/sphinx',
'12dde8afdb0a7bb5576e2656692c3478c69d8cc3',
check_version='1.4a0.dev-20151013')
pip_install('michaeljones/breathe',
'1c9d7f80378a92cffa755084823a78bb38ee4acc')
开发者ID:dpantele,项目名称:fmt,代码行数:32,代码来源:build.py
示例20: test_get_path
def test_get_path(self):
if sys.platform == 'darwin' and sys._framework:
scheme = 'osx_framework_user'
else:
scheme = os.name + '_user'
self.assertEqual(site._get_path(site._getuserbase()),
sysconfig.get_path('purelib', scheme))
开发者ID:1st1,项目名称:cpython,代码行数:7,代码来源:test_site.py
注:本文中的sysconfig.get_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论