From 6ca45d1964e2a3e999f8723821e56ec82f906006 Mon Sep 17 00:00:00 2001
From: Yap Sok Ann <sokann@gmail.com>
Date: Tue, 10 Sep 2013 11:22:06 +0800
Subject: [PATCH] Locate easy_install path after (optionally) creating
 virtualenv.

Without this, the first call to the easy_install module with a new virtualenv
will only create the virtualenv without installing the intended package, since
the `_is_package_installed` check will succeed as running /usr/bin/easy_install
as non-root user will return permission denied error with empty stdout.
---
 packaging/easy_install | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/packaging/easy_install b/packaging/easy_install
index a18b2f7d701..4110ce154a1 100644
--- a/packaging/easy_install
+++ b/packaging/easy_install
@@ -94,7 +94,6 @@ def main():
 
     name = module.params['name']
     env = module.params['virtualenv']
-    easy_install = module.get_bin_path('easy_install', True, ['%s/bin' % env])
     site_packages = module.params['virtualenv_site_packages']
     virtualenv_command = module.params['virtualenv_command']
 
@@ -117,6 +116,8 @@ def main():
             out += out_venv
             err += err_venv
 
+    easy_install = module.get_bin_path('easy_install', True, ['%s/bin' % env])
+
     cmd = None
     changed = False
     installed = _is_package_installed(module, name, easy_install)