當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。