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


Python site.ENABLE_USER_SITE属性代码示例

本文整理汇总了Python中site.ENABLE_USER_SITE属性的典型用法代码示例。如果您正苦于以下问题:Python site.ENABLE_USER_SITE属性的具体用法?Python site.ENABLE_USER_SITE怎么用?Python site.ENABLE_USER_SITE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在site的用法示例。


在下文中一共展示了site.ENABLE_USER_SITE属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: import site [as 别名]
# 或者: from site import ENABLE_USER_SITE [as 别名]
def setUp(self):
        self.dir = tempfile.mkdtemp()
        setup = os.path.join(self.dir, 'setup.py')
        f = open(setup, 'w')
        f.write(SETUP_PY)
        f.close()
        self.old_cwd = os.getcwd()
        os.chdir(self.dir)

        self.old_enable_site = site.ENABLE_USER_SITE
        self.old_file = easy_install_pkg.__file__
        self.old_base = site.USER_BASE
        site.USER_BASE = tempfile.mkdtemp()
        self.old_site = site.USER_SITE
        site.USER_SITE = tempfile.mkdtemp()
        easy_install_pkg.__file__ = site.USER_SITE 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:18,代码来源:test_easy_install.py

示例2: setUpModule

# 需要导入模块: import site [as 别名]
# 或者: from site import ENABLE_USER_SITE [as 别名]
def setUpModule():
    global OLD_SYS_PATH
    OLD_SYS_PATH = sys.path[:]

    if site.ENABLE_USER_SITE and not os.path.isdir(site.USER_SITE):
        # need to add user site directory for tests
        try:
            os.makedirs(site.USER_SITE)
            # modify sys.path: will be restored by tearDownModule()
            site.addsitedir(site.USER_SITE)
        except OSError as exc:
            if exc.errno in (errno.EACCES, errno.EPERM):
                raise unittest.SkipTest('unable to create user site directory (%r): %s'
                                        % (site.USER_SITE, exc))
            else:
                raise 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_site.py

示例3: get_site_packages

# 需要导入模块: import site [as 别名]
# 或者: from site import ENABLE_USER_SITE [as 别名]
def get_site_packages():  # pragma: no cover
    try:
        paths = site.getsitepackages()
        if site.ENABLE_USER_SITE:
            paths.append(site.getusersitepackages())
        return paths

    # virtualenv does not ship with a getsitepackages impl so we fallback
    # to using distutils if we can
    # https://github.com/pypa/virtualenv/issues/355
    except Exception:
        try:
            from distutils.sysconfig import get_python_lib

            return [get_python_lib()]

        # just incase, don't fail here, it's not worth it
        except Exception:
            return []


################################################
# cross-compatible metaclass implementation
# Copyright (c) 2010-2012 Benjamin Peterson 
开发者ID:Pylons,项目名称:hupper,代码行数:26,代码来源:compat.py

示例4: get_exe_dirs

# 需要导入模块: import site [as 别名]
# 或者: from site import ENABLE_USER_SITE [as 别名]
def get_exe_dirs():
    result = []
    if site.ENABLE_USER_SITE:
        if platform.system() == "Windows":
            if site.getusersitepackages():
                result.append(site.getusersitepackages().replace("site-packages", "Scripts"))
        else:
            if site.getuserbase():
                result.append(site.getuserbase() + "/bin")

    main_scripts = os.path.join(sys.prefix, "Scripts")
    if os.path.isdir(main_scripts) and main_scripts not in result:
        result.append(main_scripts)

    if os.path.dirname(sys.executable) not in result:
        result.append(os.path.dirname(sys.executable))

    return result 
开发者ID:thonny,项目名称:thonny,代码行数:20,代码来源:common.py

示例5: _fix_install_dir_for_user_site

# 需要导入模块: import site [as 别名]
# 或者: from site import ENABLE_USER_SITE [as 别名]
def _fix_install_dir_for_user_site(self):
        """
        Fix the install_dir if "--user" was used.
        """
        if not self.user or not site.ENABLE_USER_SITE:
            return

        self.create_home_path()
        if self.install_userbase is None:
            msg = "User base directory is not specified"
            raise DistutilsPlatformError(msg)
        self.install_base = self.install_platbase = self.install_userbase
        scheme_name = os.name.replace('posix', 'unix') + '_user'
        self.select_scheme(scheme_name) 
开发者ID:jpush,项目名称:jbox,代码行数:16,代码来源:easy_install.py

示例6: tearDown

# 需要导入模块: import site [as 别名]
# 或者: from site import ENABLE_USER_SITE [as 别名]
def tearDown(self):
        os.chdir(self.old_cwd)
        shutil.rmtree(self.dir)

        shutil.rmtree(site.USER_BASE)
        shutil.rmtree(site.USER_SITE)
        site.USER_BASE = self.old_base
        site.USER_SITE = self.old_site
        site.ENABLE_USER_SITE = self.old_enable_site
        easy_install_pkg.__file__ = self.old_file 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:12,代码来源:test_easy_install.py

示例7: test_user_install_implied

# 需要导入模块: import site [as 别名]
# 或者: from site import ENABLE_USER_SITE [as 别名]
def test_user_install_implied(self):
        site.ENABLE_USER_SITE = True # disabled sometimes
        #XXX: replace with something meaningfull
        dist = Distribution()
        dist.script_name = 'setup.py'
        cmd = easy_install(dist)
        cmd.args = ['py']
        cmd.ensure_finalized()
        self.assertTrue(cmd.user, 'user should be implied') 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:11,代码来源:test_easy_install.py

示例8: test_user_install_not_implied_without_usersite_enabled

# 需要导入模块: import site [as 别名]
# 或者: from site import ENABLE_USER_SITE [as 别名]
def test_user_install_not_implied_without_usersite_enabled(self):
        site.ENABLE_USER_SITE = False # usually enabled
        #XXX: replace with something meaningfull
        dist = Distribution()
        dist.script_name = 'setup.py'
        cmd = easy_install(dist)
        cmd.args = ['py']
        cmd.initialize_options()
        self.assertFalse(cmd.user, 'NOT user should be implied') 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:11,代码来源:test_easy_install.py

示例9: test_no_home_directory

# 需要导入模块: import site [as 别名]
# 或者: from site import ENABLE_USER_SITE [as 别名]
def test_no_home_directory(self):
        # bpo-10496: getuserbase() and getusersitepackages() must not fail if
        # the current user has no home directory (if expanduser() returns the
        # path unchanged).
        site.USER_SITE = None
        site.USER_BASE = None
        sysconfig._CONFIG_VARS = None

        with EnvironmentVarGuard() as environ, \
             support.swap_attr(os.path, 'expanduser', lambda path: path):

            del environ['PYTHONUSERBASE']
            del environ['APPDATA']

            user_base = site.getuserbase()
            self.assertTrue(user_base.startswith('~' + os.sep),
                            user_base)

            user_site = site.getusersitepackages()
            self.assertTrue(user_site.startswith(user_base), user_site)

        def fake_isdir(path):
            fake_isdir.arg = path
            return False
        fake_isdir.arg = None

        def must_not_be_called(*args):
            raise AssertionError

        with support.swap_attr(os.path, 'isdir', fake_isdir), \
             support.swap_attr(site, 'addsitedir', must_not_be_called), \
             support.swap_attr(site, 'ENABLE_USER_SITE', True):

            # addusersitepackages() must not add user_site to sys.path
            # if it is not an existing directory
            known_paths = set()
            site.addusersitepackages(known_paths)

            self.assertEqual(fake_isdir.arg, user_site)
            self.assertFalse(known_paths) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:42,代码来源:test_site.py


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