当前位置: 首页>>代码示例>>Python>>正文


Python site.PREFIXES属性代码示例

本文整理汇总了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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:test_site.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_site.py

示例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 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_site.py

示例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) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:35,代码来源:test_site.py

示例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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:10,代码来源:test_site.py

示例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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:11,代码来源:test_site.py

示例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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:29,代码来源:test_site.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:31,代码来源:test_site.py

示例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)) 
开发者ID:PyCQA,项目名称:flake8-bugbear,代码行数:11,代码来源:test_bugbear.py

示例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) 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:35,代码来源:test_site.py

示例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 
开发者ID:sassoftware,项目名称:conary,代码行数:56,代码来源:packagepolicy.py


注:本文中的site.PREFIXES属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。