本文整理匯總了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')