Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 553762 | Differences between
and this patch

Collapse All | Expand All

(-)a/pip/utils/__init__.py (-9 / +27 lines)
Lines 275-296 def renames(old, new): Link Here
275
275
276
def is_local(path):
276
def is_local(path):
277
    """
277
    """
278
    Return True if path is within sys.prefix, if we're running in a virtualenv.
278
    Return True if this is a path pip is allowed to modify.
279
279
280
    If we're not in a virtualenv, all paths are considered "local."
280
    If we're in a virtualenv, sys.prefix points to the virtualenv's
281
    prefix; only sys.prefix is considered local.
282
283
    If we're not in a virtualenv, in general we can modify anything.
284
    However, if the OS vendor has configured distutils to install
285
    somewhere other than sys.prefix (which could be a subdirectory of
286
    sys.prefix, e.g. /usr/local), we consider sys.prefix itself nonlocal
287
    and the domain of the OS vendor. (In other words, everything _other
288
    than_ sys.prefix is considered local.)
281
289
282
    """
290
    """
283
    if not running_under_virtualenv():
291
284
        return True
292
    path = normalize_path(path)
285
    return normalize_path(path).startswith(normalize_path(sys.prefix))
293
    prefix = normalize_path(sys.prefix)
294
295
    if running_under_virtualenv():
296
        return path.startswith(normalize_path(sys.prefix))
297
    else:
298
        from pip.locations import distutils_scheme
299
        if path.startswith(prefix):
300
            for local_path in distutils_scheme("").values():
301
                if path.startswith(normalize_path(local_path)):
302
                    return True
303
            return False
304
        else:
305
            return True
286
306
287
307
288
def dist_is_local(dist):
308
def dist_is_local(dist):
289
    """
309
    """
290
    Return True if given Distribution object is installed locally
310
    Return True if given Distribution object is installed somewhere pip
291
    (i.e. within current virtualenv).
311
    is allowed to modify.
292
293
    Always True if we're not in a virtualenv.
294
312
295
    """
313
    """
296
    return is_local(dist_location(dist))
314
    return is_local(dist_location(dist))

Return to bug 553762