本文整理汇总了Python中distutils.sysconfig.get_python_lib方法的典型用法代码示例。如果您正苦于以下问题:Python sysconfig.get_python_lib方法的具体用法?Python sysconfig.get_python_lib怎么用?Python sysconfig.get_python_lib使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distutils.sysconfig
的用法示例。
在下文中一共展示了sysconfig.get_python_lib方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _compute_site_packages
# 需要导入模块: from distutils import sysconfig [as 别名]
# 或者: from distutils.sysconfig import get_python_lib [as 别名]
def _compute_site_packages():
def _normalized_path(path):
return os.path.normcase(os.path.abspath(path))
paths = set()
real_prefix = getattr(sys, 'real_prefix', None)
for prefix in filter(None, (real_prefix, sys.prefix)):
path = sysconfig.get_python_lib(prefix=prefix)
path = _normalized_path(path)
paths.add(path)
# Handle Debian's derivatives /usr/local.
if os.path.isfile("/etc/debian_version"):
for prefix in filter(None, (real_prefix, sys.prefix)):
libpython = os.path.join(prefix, "local", "lib",
"python" + sysconfig.get_python_version(),
"dist-packages")
paths.add(libpython)
return paths
示例2: _compute_site_packages
# 需要导入模块: from distutils import sysconfig [as 别名]
# 或者: from distutils.sysconfig import get_python_lib [as 别名]
def _compute_site_packages():
def _normalized_path(path):
return os.path.normcase(os.path.abspath(path))
paths = set()
real_prefix = getattr(sys, "real_prefix", None)
for prefix in filter(None, (real_prefix, sys.prefix)):
path = sysconfig.get_python_lib(prefix=prefix)
path = _normalized_path(path)
paths.add(path)
# Handle Debian's derivatives /usr/local.
if os.path.isfile("/etc/debian_version"):
for prefix in filter(None, (real_prefix, sys.prefix)):
libpython = os.path.join(
prefix,
"local",
"lib",
"python" + sysconfig.get_python_version(),
"dist-packages",
)
paths.add(libpython)
return paths
示例3: find_package_names
# 需要导入模块: from distutils import sysconfig [as 别名]
# 或者: from distutils.sysconfig import get_python_lib [as 别名]
def find_package_names():
site_packages = sysconfig.get_python_lib()
# initialize with well-known packages that don't seem to have a top_level.txt
res = {
'yaml': 'PyYAML',
'Crypto': 'pycrypto',
}
for pth in os.listdir(site_packages):
if not pth.endswith('.dist-info'):
continue
pkgname = pth.split('-', 1)[0].replace('_', '-')
top_level_fname = os.path.join(site_packages, pth, 'top_level.txt')
if not os.path.exists(top_level_fname):
if pkgname not in res.values():
print("ERR:", pth, 'has not top_level.txt')
continue
for modname in open(top_level_fname).read().split():
modname = modname.replace('/', '.')
if modname.startswith(r'win32\lib'):
modname = modname.rsplit('\\')[1]
res[modname] = pkgname
return res
示例4: __init__
# 需要导入模块: from distutils import sysconfig [as 别名]
# 或者: from distutils.sysconfig import get_python_lib [as 别名]
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]
示例5: _extras_paths
# 需要导入模块: from distutils import sysconfig [as 别名]
# 或者: from distutils.sysconfig import get_python_lib [as 别名]
def _extras_paths(cls):
standard_lib = sysconfig.get_python_lib(standard_lib=True)
try:
makefile = sysconfig.parse_makefile(sysconfig.get_makefile_filename())
except (AttributeError, IOError):
# This is not available by default in PyPy's distutils.sysconfig or it simply is
# no longer available on the system (IOError ENOENT)
makefile = {}
extras_paths = filter(None, makefile.get('EXTRASPATH', '').split(':'))
for path in extras_paths:
yield os.path.join(standard_lib, path)
# Handle .pth injected paths as extras.
sitedirs = cls._get_site_packages()
for pth_path in cls._scan_pth_files(sitedirs):
TRACER.log('Found .pth file: %s' % pth_path, V=3)
for extras_path in iter_pth_paths(pth_path):
yield extras_path
示例6: vcsrepo
# 需要导入模块: from distutils import sysconfig [as 别名]
# 或者: from distutils.sysconfig import get_python_lib [as 别名]
def vcsrepo(self, repo):
# type (VCSRepository) -> None
self._vcsrepo = repo
ireq = self.ireq
wheel_kwargs = self.wheel_kwargs.copy()
wheel_kwargs["src_dir"] = repo.checkout_directory
with pip_shims.shims.global_tempdir_manager(), temp_path():
ireq.ensure_has_source_dir(wheel_kwargs["src_dir"])
sys.path = [repo.checkout_directory, "", ".", get_python_lib(plat_specific=0)]
setupinfo = SetupInfo.create(
repo.checkout_directory,
ireq=ireq,
subdirectory=self.subdirectory,
kwargs=wheel_kwargs,
)
self._setup_info = setupinfo
self._setup_info.reload()
示例7: get_site_packages
# 需要导入模块: from distutils import sysconfig [as 别名]
# 或者: from distutils.sysconfig import get_python_lib [as 别名]
def get_site_packages(): # pragma: no cover
try:
paths = site.getsitepackages()
if site.ENABLE_USER_SITE:
paths.append(site.getusersitepackages())
return paths
# virtualenv does not ship with a getsitepackages impl so we fallback
# to using distutils if we can
# https://github.com/pypa/virtualenv/issues/355
except Exception:
try:
from distutils.sysconfig import get_python_lib
return [get_python_lib()]
# just incase, don't fail here, it's not worth it
except Exception:
return []
################################################
# cross-compatible metaclass implementation
# Copyright (c) 2010-2012 Benjamin Peterson
示例8: __init__
# 需要导入模块: from distutils import sysconfig [as 别名]
# 或者: from distutils.sysconfig import get_python_lib [as 别名]
def __init__(self):
"""Initialize a new DistFilesFinder."""
try:
self.sitedirs = set(site.getsitepackages() + [site.getusersitepackages()])
except AttributeError:
self.sitedirs = [get_python_lib()]
示例9: get_stdlib
# 需要导入模块: from distutils import sysconfig [as 别名]
# 或者: from distutils.sysconfig import get_python_lib [as 别名]
def get_stdlib():
paths = [
sysconfig.get_python_lib(standard_lib=True),
sysconfig.get_python_lib(standard_lib=True, plat_specific=True),
]
return set(filter(bool, paths))
示例10: get_path
# 需要导入模块: from distutils import sysconfig [as 别名]
# 或者: from distutils.sysconfig import get_python_lib [as 别名]
def get_path(name):
if name not in ('platlib', 'purelib'):
raise ValueError("Name must be purelib or platlib")
return get_python_lib(name=='platlib')
示例11: _get_purelib
# 需要导入模块: from distutils import sysconfig [as 别名]
# 或者: from distutils.sysconfig import get_python_lib [as 别名]
def _get_purelib():
return get_python_lib(False)
示例12: collect_stdlib_distributions
# 需要导入模块: from distutils import sysconfig [as 别名]
# 或者: from distutils.sysconfig import get_python_lib [as 别名]
def collect_stdlib_distributions():
"""Yield a conventional spec and the names of all top_level standard library modules."""
distribution_spec = 'Python==%d.%d.%d' % sys.version_info[:3]
stdlib_path = sysconfig.get_python_lib(standard_lib=True)
distribution_top_level = [name for _, name, _ in pkgutil.iter_modules(path=[stdlib_path])]
distribution_top_level += list(sys.builtin_module_names)
yield distribution_spec, distribution_top_level
示例13: _determine_location_for
# 需要导入模块: from distutils import sysconfig [as 别名]
# 或者: from distutils.sysconfig import get_python_lib [as 别名]
def _determine_location_for(self, path):
parts = path.split(os.path.sep)
# Heuristic classifier
if 'site-packages' in parts:
return '3'
elif _PYTHON_VERSION in parts:
return 'S'
# Use table from sysconfig.get_python_lib()
for dir, location in self.lib_locations:
if path.startswith(dir):
return location
return 'L'
示例14: get_path
# 需要导入模块: from distutils import sysconfig [as 别名]
# 或者: from distutils.sysconfig import get_python_lib [as 别名]
def get_path(name):
if name not in ('platlib', 'purelib'):
raise ValueError("Name must be purelib or platlib")
return get_python_lib(name == 'platlib')