本文整理汇总了Python中sysconfig.get_path方法的典型用法代码示例。如果您正苦于以下问题:Python sysconfig.get_path方法的具体用法?Python sysconfig.get_path怎么用?Python sysconfig.get_path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sysconfig
的用法示例。
在下文中一共展示了sysconfig.get_path方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getusersitepackages
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_path [as 别名]
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
import os
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
示例2: _get_library_dir
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_path [as 别名]
def _get_library_dir():
library_dir = None
try:
import sysconfig
library_dir = sysconfig.get_path('purelib')
except ImportError:
pass # i.e.: Only 2.7 onwards
if library_dir is None or not os_path_exists(library_dir):
for path in sys.path:
if os_path_exists(path) and os.path.basename(path) == 'site-packages':
library_dir = path
break
if library_dir is None or not os_path_exists(library_dir):
library_dir = os.path.dirname(os.__file__)
return library_dir
# Note: we can't call sysconfig.get_path from _NormPath (it deadlocks on Python 2.7) so, we
# need to get the library dir during module loading.
示例3: getusersitepackages
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_path [as 别名]
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
USER_SITE = get_path('purelib', '%s_user' % os.name)
return USER_SITE
示例4: get_stdlib
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_path [as 别名]
def get_stdlib():
paths = [
sysconfig.get_path("stdlib"),
sysconfig.get_path("platstdlib"),
]
return set(filter(bool, paths))
示例5: get_path
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_path [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')
示例6: _get_purelib
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_path [as 别名]
def _get_purelib():
return get_path("purelib")
示例7: get_path
# 需要导入模块: import sysconfig [as 别名]
# 或者: from sysconfig import get_path [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')