Skip to content

Commit

Permalink
make monkey-patching work again in tests/test_user_site.py
Browse files Browse the repository at this point in the history
Monkey-patching 'pip.util.dist_in_site_packages' through
'sitecustomize.py' in 'tests/test_user_site.py' wasn't working unless
the fully qualitifed path to 'dist_in_site_packages' was
used.
  • Loading branch information
gvalkov committed Nov 10, 2012
1 parent 2c64a1e commit 7746051
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pip/req.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import tempfile
import zipfile

import pip

from distutils.util import change_root
from pip.locations import bin_py, running_under_virtualenv
from pip.exceptions import (InstallationError, UninstallationError,
Expand All @@ -18,7 +20,7 @@
from pip.util import display_path, rmtree
from pip.util import ask, ask_path_exists, backup_dir
from pip.util import is_installable_dir, is_local, dist_is_local, dist_in_usersite
from pip.util import renames, normalize_path, egg_link_path, dist_in_site_packages
from pip.util import renames, normalize_path, egg_link_path
from pip.util import make_path_relative
from pip.util import call_subprocess
from pip.backwardcompat import (urlparse, urllib, uses_pycache,
Expand Down Expand Up @@ -680,6 +682,7 @@ def check_if_exists(self):
"""Find an installed distribution that satisfies or conflicts
with this requirement, and set self.satisfied_by or
self.conflicts_with appropriately."""

if self.req is None:
return False
try:
Expand All @@ -691,7 +694,7 @@ def check_if_exists(self):
if self.use_user_site:
if dist_in_usersite(existing_dist):
self.conflicts_with = existing_dist
elif running_under_virtualenv() and dist_in_site_packages(existing_dist):
elif running_under_virtualenv() and pip.util.dist_in_site_packages(existing_dist):
raise InstallationError("Will not install to the user site because it will lack sys.path precedence to %s in %s"
%(existing_dist.project_name, existing_dist.location))
else:
Expand Down

0 comments on commit 7746051

Please sign in to comment.