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


Python site.__file__方法代码示例

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


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

示例1: has_system_site_packages

# 需要导入模块: import site [as 别名]
# 或者: from site import __file__ [as 别名]
def has_system_site_packages(interpreter):
    # TODO: unit-test
    system_site_packages = check_output((
        interpreter,
        '-c',
        # stolen directly from virtualenv's site.py
        """\
import site, os.path
print(
    0
    if os.path.exists(
        os.path.join(os.path.dirname(site.__file__), 'no-global-site-packages.txt')
    ) else
    1
)"""
    ))
    system_site_packages = int(system_site_packages)
    assert system_site_packages in (0, 1)
    return bool(system_site_packages) 
开发者ID:edmundmok,项目名称:mealpy,代码行数:21,代码来源:venv_update.py

示例2: exec_scratch_virtualenv

# 需要导入模块: import site [as 别名]
# 或者: from site import __file__ [as 别名]
def exec_scratch_virtualenv(args):
    """
    goals:
        - get any random site-packages off of the pythonpath
        - ensure we can import virtualenv
        - ensure that we're not using the interpreter that we may need to delete
        - idempotency: do nothing if the above goals are already met
    """
    scratch = Scratch()
    if not exists(scratch.python):
        run(('virtualenv', scratch.venv))

    if not exists(join(scratch.src, 'virtualenv.py')):
        scratch_python = venv_python(scratch.venv)
        # TODO: do we allow user-defined override of which version of virtualenv to install?
        tmp = scratch.src + '.tmp'
        run((scratch_python, '-m', 'pip.__main__', 'install', 'virtualenv', '--target', tmp))

        from os import rename
        rename(tmp, scratch.src)

    import sys
    from os.path import realpath
    # We want to compare the paths themselves as sometimes sys.path is the same
    # as scratch.venv, but with a suffix of bin/..
    if realpath(sys.prefix) != realpath(scratch.venv):
        # TODO-TEST: sometimes we would get a stale version of venv-update
        exec_((scratch.python, dotpy(__file__)) + args)  # never returns

    # TODO-TEST: the original venv-update's directory was on sys.path (when using symlinking)
    sys.path[0] = scratch.src 
开发者ID:edmundmok,项目名称:mealpy,代码行数:33,代码来源:venv_update.py

示例3: execfile_

# 需要导入模块: import site [as 别名]
# 或者: from site import __file__ [as 别名]
def execfile_(filename):
    with open(filename) as code:
        code = compile(code.read(), filename, 'exec')
        exec(code, {'__file__': filename}) 
开发者ID:edmundmok,项目名称:mealpy,代码行数:6,代码来源:venv_update.py

示例4: virtualenv_no_global

# 需要导入模块: import site [as 别名]
# 或者: from site import __file__ [as 别名]
def virtualenv_no_global():
    """
    Return True if in a venv and no system site packages.
    """
    # this mirrors the logic in virtualenv.py for locating the
    # no-global-site-packages.txt file
    site_mod_dir = os.path.dirname(os.path.abspath(site.__file__))
    no_global_file = os.path.join(site_mod_dir, 'no-global-site-packages.txt')
    if running_under_virtualenv() and os.path.isfile(no_global_file):
        return True 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:locations.py

示例5: virtualenv_no_global

# 需要导入模块: import site [as 别名]
# 或者: from site import __file__ [as 别名]
def virtualenv_no_global():
    """
    Return True if in a venv and no system site packages.
    """
    #this mirrors the logic in virtualenv.py for locating the no-global-site-packages.txt file
    site_mod_dir = os.path.dirname(os.path.abspath(site.__file__))
    no_global_file = os.path.join(site_mod_dir, 'no-global-site-packages.txt')
    if running_under_virtualenv() and os.path.isfile(no_global_file):
        return True 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:11,代码来源:locations.py

示例6: virtualenv_no_global

# 需要导入模块: import site [as 别名]
# 或者: from site import __file__ [as 别名]
def virtualenv_no_global():
    # type: () -> bool
    """
    Return True if in a venv and no system site packages.
    """
    # this mirrors the logic in virtualenv.py for locating the
    # no-global-site-packages.txt file
    site_mod_dir = os.path.dirname(os.path.abspath(site.__file__))
    no_global_file = os.path.join(site_mod_dir, 'no-global-site-packages.txt')
    if running_under_virtualenv() and os.path.isfile(no_global_file):
        return True
    else:
        return False 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:15,代码来源:locations.py

示例7: _no_global_under_regular_virtualenv

# 需要导入模块: import site [as 别名]
# 或者: from site import __file__ [as 别名]
def _no_global_under_regular_virtualenv():
    # type: () -> bool
    """Check if "no-global-site-packages.txt" exists beside site.py

    This mirrors logic in pypa/virtualenv for determining whether system
    site-packages are visible in the virtual environment.
    """
    site_mod_dir = os.path.dirname(os.path.abspath(site.__file__))
    no_global_site_packages_file = os.path.join(
        site_mod_dir, 'no-global-site-packages.txt',
    )
    return os.path.exists(no_global_site_packages_file) 
开发者ID:pantsbuild,项目名称:pex,代码行数:14,代码来源:virtualenv.py


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