{"action":"created","issue":{"url":"https://api.github.com/repos/pypa/pip/issues/3029","labels_url":"https://api.github.com/repos/pypa/pip/issues/3029/labels{/name}","comments_url":"https://api.github.com/repos/pypa/pip/issues/3029/comments","events_url":"https://api.github.com/repos/pypa/pip/issues/3029/events","html_url":"https://github.com/pypa/pip/issues/3029","id":100838306,"number":3029,"title":"Using `--root` option checks existing installation in global site-packages (instead of given dir)","user":{"login":"asfaltboy","id":321520,"avatar_url":"https://avatars.githubusercontent.com/u/321520?v=3","gravatar_id":"","url":"https://api.github.com/users/asfaltboy","html_url":"https://github.com/asfaltboy","followers_url":"https://api.github.com/users/asfaltboy/followers","following_url":"https://api.github.com/users/asfaltboy/following{/other_user}","gists_url":"https://api.github.com/users/asfaltboy/gists{/gist_id}","starred_url":"https://api.github.com/users/asfaltboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asfaltboy/subscriptions","organizations_url":"https://api.github.com/users/asfaltboy/orgs","repos_url":"https://api.github.com/users/asfaltboy/repos","events_url":"https://api.github.com/users/asfaltboy/events{/privacy}","received_events_url":"https://api.github.com/users/asfaltboy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-13T18:34:58Z","updated_at":"2015-09-06T08:11:07Z","closed_at":null,"body":"For instance, if I have no `requests` package installed globally, running `pip install --root=$DIR requests==2.7` installs the package into `$DIR/usr/lib/python27/site-packages`; and subsequent re-runs do the same even when the package exists.\r\n\r\nAlternatively installing `requests` globally prevents `--root` from ever running, returning the familiar `Requirement already satisfied` message pointing at the global site-packages (for me, on OSX it shows `/usr/local/lib/python2.7/site-packages`).\r\n\r\nBy the way, `--no-use-wheel` does not seem to have an effect on this."},"comment":{"url":"https://api.github.com/repos/pypa/pip/issues/comments/138051671","html_url":"https://github.com/pypa/pip/issues/3029#issuecomment-138051671","issue_url":"https://api.github.com/repos/pypa/pip/issues/3029","id":138051671,"user":{"login":"asfaltboy","id":321520,"avatar_url":"https://avatars.githubusercontent.com/u/321520?v=3","gravatar_id":"","url":"https://api.github.com/users/asfaltboy","html_url":"https://github.com/asfaltboy","followers_url":"https://api.github.com/users/asfaltboy/followers","following_url":"https://api.github.com/users/asfaltboy/following{/other_user}","gists_url":"https://api.github.com/users/asfaltboy/gists{/gist_id}","starred_url":"https://api.github.com/users/asfaltboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asfaltboy/subscriptions","organizations_url":"https://api.github.com/users/asfaltboy/orgs","repos_url":"https://api.github.com/users/asfaltboy/repos","events_url":"https://api.github.com/users/asfaltboy/events{/privacy}","received_events_url":"https://api.github.com/users/asfaltboy/received_events","type":"User","site_admin":false},"created_at":"2015-09-06T08:11:07Z","updated_at":"2015-09-06T08:11:07Z","body":"I don't think that the behaviour of `--root` during setup itself is an issue, rather the extra prep work done by pip is slightly inconsistent:\r\n\r\n1. I found that running `python setup.py install --root=$DIR` directly always behaves the same, it install the package under `$DIR/usr/lib/python27/site-packages`, and does not (seem to) check if the package already installed. This means that the first \"part\" of my issue description above, i.e _install always ignores existing package even if in `$DIR`_, performs the same as setup.py, for better or worse.\r\n\r\n2. Now for the second part, i.e _pip reports package is already installed globally_. Tracing through calls with `pdb` lead me to a call to [InstallRequirement.check_if_exists](https://github.com/pypa/pip/blob/ec990fdbcb8c1ca5ac10eac47759d9631d45d7cd/pip/req/req_install.py#L954) which subsequently aborts the install, since the package is found on sys.path.\r\n\r\nI feel that pip behaviour should at least be consistent in both cases, and it may be simplest to skip \"requirement exists\" test if root is passed ([see entry point into `RequirementSet.prepare_files`](https://github.com/pypa/pip/blob/ec990fdbcb8c1ca5ac10eac47759d9631d45d7cd/pip/commands/install.py#L306)).\r\n\r\nHowever, personally, I think it would be more useful to temporarily have sys.path use target root `$DIR` (only?) so that all requirements tests run only for that location; with the intention of making `--root` in line with other pip functionality. However, I'm not sure of the full consequences of this."}}