當前位置: 首頁>>代碼示例>>Python>>正文


Python locations.running_under_virtualenv方法代碼示例

本文整理匯總了Python中pip.locations.running_under_virtualenv方法的典型用法代碼示例。如果您正苦於以下問題:Python locations.running_under_virtualenv方法的具體用法?Python locations.running_under_virtualenv怎麽用?Python locations.running_under_virtualenv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pip.locations的用法示例。


在下文中一共展示了locations.running_under_virtualenv方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: load_selfcheck_statefile

# 需要導入模塊: from pip import locations [as 別名]
# 或者: from pip.locations import running_under_virtualenv [as 別名]
def load_selfcheck_statefile():
    if running_under_virtualenv():
        return VirtualenvSelfCheckState()
    else:
        return GlobalSelfCheckState() 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:7,代碼來源:outdated.py

示例2: is_local

# 需要導入模塊: from pip import locations [as 別名]
# 或者: from pip.locations import running_under_virtualenv [as 別名]
def is_local(path):
    """
    Return True if path is within sys.prefix, if we're running in a virtualenv.

    If we're not in a virtualenv, all paths are considered "local."

    """
    if not running_under_virtualenv():
        return True
    return normalize_path(path).startswith(normalize_path(sys.prefix)) 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:12,代碼來源:util.py

示例3: egg_link_path

# 需要導入模塊: from pip import locations [as 別名]
# 或者: from pip.locations import running_under_virtualenv [as 別名]
def egg_link_path(dist):
    """
    Return the path for the .egg-link file if it exists, otherwise, None.

    There's 3 scenarios:
    1) not in a virtualenv
       try to find in site.USER_SITE, then site_packages
    2) in a no-global virtualenv
       try to find in site_packages
    3) in a yes-global virtualenv
       try to find in site_packages, then site.USER_SITE  (don't look in global location)

    For #1 and #3, there could be odd cases, where there's an egg-link in 2 locations.
    This method will just return the first one found.
    """
    sites = []
    if running_under_virtualenv():
        if virtualenv_no_global():
            sites.append(site_packages)
        else:
            sites.append(site_packages)
            if user_site:
                sites.append(user_site)
    else:
        if user_site:
            sites.append(user_site)
        sites.append(site_packages)

    for site in sites:
        egglink = os.path.join(site, dist.project_name) + '.egg-link'
        if os.path.isfile(egglink):
            return egglink 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:34,代碼來源:util.py


注:本文中的pip.locations.running_under_virtualenv方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。