本文整理汇总了Python中site.PREFIXES属性的典型用法代码示例。如果您正苦于以下问题:Python site.PREFIXES属性的具体用法?Python site.PREFIXES怎么用?Python site.PREFIXES使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类site
的用法示例。
在下文中一共展示了site.PREFIXES属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getsitepackages
# 需要导入模块: import site [as 别名]
# 或者: from site import PREFIXES [as 别名]
def test_getsitepackages(self):
site.PREFIXES = ['xoxo']
dirs = site.getsitepackages()
if sys.platform in ('os2emx', 'riscos'):
self.assertEqual(len(dirs), 1)
wanted = os.path.join('xoxo', 'Lib', 'site-packages')
self.assertEqual(dirs[0], wanted)
elif os.sep == '/':
# OS X, Linux, FreeBSD, etc
self.assertEqual(len(dirs), 2)
wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
'site-packages')
self.assertEqual(dirs[0], wanted)
wanted = os.path.join('xoxo', 'lib', 'site-python')
self.assertEqual(dirs[1], wanted)
else:
# other platforms
self.assertEqual(len(dirs), 2)
self.assertEqual(dirs[0], 'xoxo')
wanted = os.path.join('xoxo', 'lib', 'site-packages')
self.assertEqual(dirs[1], wanted)
示例2: setUp
# 需要导入模块: import site [as 别名]
# 或者: from site import PREFIXES [as 别名]
def setUp(self):
"""Save a copy of sys.path"""
self.sys_path = sys.path[:]
self.old_base = site.USER_BASE
self.old_site = site.USER_SITE
self.old_prefixes = site.PREFIXES
self.old_vars = copy(sysconfig._CONFIG_VARS)
示例3: tearDown
# 需要导入模块: import site [as 别名]
# 或者: from site import PREFIXES [as 别名]
def tearDown(self):
"""Restore sys.path"""
sys.path[:] = self.sys_path
site.USER_BASE = self.old_base
site.USER_SITE = self.old_site
site.PREFIXES = self.old_prefixes
sysconfig._CONFIG_VARS = self.old_vars
示例4: test_getsitepackages
# 需要导入模块: import site [as 别名]
# 或者: from site import PREFIXES [as 别名]
def test_getsitepackages(self):
site.PREFIXES = ['xoxo']
dirs = site.getsitepackages()
if sys.platform in ('os2emx', 'riscos'):
self.assertEqual(len(dirs), 1)
wanted = os.path.join('xoxo', 'Lib', 'site-packages')
self.assertEqual(dirs[0], wanted)
elif (sys.platform == "darwin" and
sysconfig.get_config_var("PYTHONFRAMEWORK")):
# OS X framework builds
site.PREFIXES = ['Python.framework']
dirs = site.getsitepackages()
self.assertEqual(len(dirs), 3)
wanted = os.path.join('/Library',
sysconfig.get_config_var("PYTHONFRAMEWORK"),
sys.version[:3],
'site-packages')
self.assertEqual(dirs[2], wanted)
elif os.sep == '/':
# OS X non-framwework builds, Linux, FreeBSD, etc
self.assertEqual(len(dirs), 2)
wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
'site-packages')
self.assertEqual(dirs[0], wanted)
wanted = os.path.join('xoxo', 'lib', 'site-python')
self.assertEqual(dirs[1], wanted)
else:
# other platforms
self.assertEqual(len(dirs), 2)
self.assertEqual(dirs[0], 'xoxo')
wanted = os.path.join('xoxo', 'lib', 'site-packages')
self.assertEqual(dirs[1], wanted)
示例5: setUp
# 需要导入模块: import site [as 别名]
# 或者: from site import PREFIXES [as 别名]
def setUp(self):
"""Save a copy of sys.path"""
self.sys_path = sys.path[:]
self.old_base = site.USER_BASE
self.old_site = site.USER_SITE
self.old_prefixes = site.PREFIXES
self.original_vars = sysconfig._CONFIG_VARS
self.old_vars = copy(sysconfig._CONFIG_VARS)
示例6: tearDown
# 需要导入模块: import site [as 别名]
# 或者: from site import PREFIXES [as 别名]
def tearDown(self):
"""Restore sys.path"""
sys.path[:] = self.sys_path
site.USER_BASE = self.old_base
site.USER_SITE = self.old_site
site.PREFIXES = self.old_prefixes
sysconfig._CONFIG_VARS = self.original_vars
sysconfig._CONFIG_VARS.clear()
sysconfig._CONFIG_VARS.update(self.old_vars)
示例7: test_getsitepackages
# 需要导入模块: import site [as 别名]
# 或者: from site import PREFIXES [as 别名]
def test_getsitepackages(self):
site.PREFIXES = ['xoxo']
dirs = site.getsitepackages()
if (sys.platform == "darwin" and
sysconfig.get_config_var("PYTHONFRAMEWORK")):
# OS X framework builds
site.PREFIXES = ['Python.framework']
dirs = site.getsitepackages()
self.assertEqual(len(dirs), 2)
wanted = os.path.join('/Library',
sysconfig.get_config_var("PYTHONFRAMEWORK"),
sys.version[:3],
'site-packages')
self.assertEqual(dirs[1], wanted)
elif os.sep == '/':
# OS X non-framwework builds, Linux, FreeBSD, etc
self.assertEqual(len(dirs), 1)
wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
'site-packages')
self.assertEqual(dirs[0], wanted)
else:
# other platforms
self.assertEqual(len(dirs), 2)
self.assertEqual(dirs[0], 'xoxo')
wanted = os.path.join('xoxo', 'lib', 'site-packages')
self.assertEqual(dirs[1], wanted)
示例8: test_getsitepackages
# 需要导入模块: import site [as 别名]
# 或者: from site import PREFIXES [as 别名]
def test_getsitepackages(self):
site.PREFIXES = ['xoxo']
dirs = site.getsitepackages()
if (sys.platform == "darwin" and
sysconfig.get_config_var("PYTHONFRAMEWORK")):
# OS X framework builds
site.PREFIXES = ['Python.framework']
dirs = site.getsitepackages()
self.assertEqual(len(dirs), 3)
wanted = os.path.join('/Library',
sysconfig.get_config_var("PYTHONFRAMEWORK"),
sys.version[:3],
'site-packages')
self.assertEqual(dirs[2], wanted)
elif os.sep == '/':
# OS X non-framwework builds, Linux, FreeBSD, etc
self.assertEqual(len(dirs), 2)
wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
'site-packages')
self.assertEqual(dirs[0], wanted)
wanted = os.path.join('xoxo', 'lib', 'site-python')
self.assertEqual(dirs[1], wanted)
else:
# other platforms
self.assertEqual(len(dirs), 2)
self.assertEqual(dirs[0], 'xoxo')
wanted = os.path.join('xoxo', 'lib', 'site-packages')
self.assertEqual(dirs[1], wanted)
示例9: test_does_not_crash_on_site_code
# 需要导入模块: import site [as 别名]
# 或者: from site import PREFIXES [as 别名]
def test_does_not_crash_on_site_code(self):
# Because the generator isn't perfect, we'll also test on all the code
# we can easily find in our current Python environment - this includes
# the standard library, and all installed packages.
for base in sorted(set(site.PREFIXES)):
for dirname, _, files in os.walk(base):
for f in files:
if f.endswith(".py"):
BugBearChecker(filename=str(Path(dirname) / f))
示例10: test_getsitepackages
# 需要导入模块: import site [as 别名]
# 或者: from site import PREFIXES [as 别名]
def test_getsitepackages(self):
site.PREFIXES = ['xoxo']
dirs = site.getsitepackages()
if sys.platform in ('os2emx', 'riscos') or is_jython:
self.assertEqual(len(dirs), 1)
wanted = os.path.join('xoxo', 'Lib', 'site-packages')
self.assertEqual(dirs[0], wanted)
elif (sys.platform == "darwin" and
sysconfig.get_config_var("PYTHONFRAMEWORK")):
# OS X framework builds
site.PREFIXES = ['Python.framework']
dirs = site.getsitepackages()
self.assertEqual(len(dirs), 3)
wanted = os.path.join('/Library',
sysconfig.get_config_var("PYTHONFRAMEWORK"),
sys.version[:3],
'site-packages')
self.assertEqual(dirs[2], wanted)
elif os.sep == '/':
# OS X non-framwework builds, Linux, FreeBSD, etc
self.assertEqual(len(dirs), 2)
wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
'site-packages')
self.assertEqual(dirs[0], wanted)
wanted = os.path.join('xoxo', 'lib', 'site-python')
self.assertEqual(dirs[1], wanted)
else:
# other platforms
self.assertEqual(len(dirs), 2)
self.assertEqual(dirs[0], 'xoxo')
wanted = os.path.join('xoxo', 'lib', 'site-packages')
self.assertEqual(dirs[1], wanted)
示例11: _getPythonSysPath
# 需要导入模块: import site [as 别名]
# 或者: from site import PREFIXES [as 别名]
def _getPythonSysPath(self, pythonPath, destdir, libdir, useDestDir=False):
"""Return the system path for the python interpreter at C{pythonPath}
@param pythonPath: Path to the target python interpreter
@param destdir: Destination root, in case of a python bootstrap
@param libdir: Destination libdir, in case of a python bootstrap
@param useDestDir: If True, look in the destdir instead.
"""
script = ["import sys, site"]
if useDestDir:
# Repoint site.py at the destdir so it picks up .pth files there.
script.extend([
"sys.path = []",
"sys.prefix = %r + sys.prefix" % (destdir,),
"sys.exec_prefix = %r + sys.exec_prefix" % (destdir,),
"site.PREFIXES = [sys.prefix, sys.exec_prefix]",
"site.addsitepackages(None)",
])
script.append(r"print('\0'.join(sys.path))")
try:
stdout = self._runPythonScript(pythonPath, destdir, libdir, script)
except (OSError, RuntimeError):
# something went wrong, don't trust any output
self.info('Could not run system python "%s", guessing sys.path...',
pythonPath)
sysPath = []
else:
sysPath = [x.strip() for x in stdout.split('\0') if x.strip()]
if not sysPath and not useDestDir:
# probably a cross-build -- let's try a decent assumption
# for the syspath.
self.info("Failed to detect system python path, using fallback")
pyVer = self._getPythonVersionFromPath(pythonPath, destdir)
if not pyVer and self.bootstrapPythonFlags is not None:
pyVer = self._getPythonVersionFromFlags(
self.bootstrapPythonFlags)
if pyVer and self.bootstrapSysPath is not None:
lib = self.recipe.macros.lib
# this list needs to include all sys.path elements that
# might be needed for python per se -- note that
# bootstrapPythonFlags and bootstrapSysPath go
# together
sysPath = self.bootstrapSysPath + [
'/usr/%s/%s' %(lib, pyVer),
'/usr/%s/%s/plat-linux2' %(lib, pyVer),
'/usr/%s/%s/lib-tk' %(lib, pyVer),
'/usr/%s/%s/lib-dynload' %(lib, pyVer),
'/usr/%s/%s/site-packages' %(lib, pyVer),
# for purelib python on x86_64
'/usr/lib/%s/site-packages' %pyVer,
]
return sysPath