From 1d1d644306e0b91813960e4513b32a384d786371 Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Mon, 7 Sep 2009 16:28:44 -0400 Subject: [PATCH] catch easy_installed script wrappers --- pip.py | 15 +++++++++++++++ tests/test_uninstall.txt | 8 ++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/pip.py b/pip.py index 5cc8c4d0e..3459989e9 100755 --- a/pip.py +++ b/pip.py @@ -62,8 +62,13 @@ else: # FIXME doesn't account for venv linked to global site-packages if sys.platform == 'win32': lib_py = os.path.join(sys.prefix, 'Lib') + bin_py = os.path.join(sys.prefix, 'Scripts') + # buildout uses 'bin' on Windows too? + if not os.path.exists(bin_py): + bin_py = os.path.join(sys.prefix, 'bin') else: lib_py = os.path.join(sys.prefix, 'lib', 'python%s' % sys.version[:3]) + bin_py = os.path.join(sys.prefix, 'bin') pypi_url = "http://pypi.python.org/simple" @@ -1755,6 +1760,14 @@ execfile(__file__) 'easy-install.pth') paths_to_remove.add_pth(easy_install_pth, dist.location) + # get scripts from metadata FIXME there seems to be no way to + # get info about installed scripts from a + # develop-install. python setup.py develop --record in + # install_editable seemingly ought to work, but does not + if dist.has_metadata('scripts') and dist.metadata_isdir('scripts'): + for script in dist.metadata_listdir('scripts'): + paths_to_remove.add(os.path.join(bin_py, script)) + paths_to_remove.remove(auto_confirm) paths_to_remove.commit() @@ -4238,6 +4251,8 @@ class UninstallPathSet(object): self._moved_paths = [] def add(self, path): + if not os.path.exists(path): + return stripped = strip_prefix(os.path.normcase(path), self.prefix) if stripped: self.paths.add(stripped) diff --git a/tests/test_uninstall.txt b/tests/test_uninstall.txt index b5048258f..baa4d0c7e 100644 --- a/tests/test_uninstall.txt +++ b/tests/test_uninstall.txt @@ -13,13 +13,13 @@ Simple install and uninstall:: >>> diff_states(result.files_before, result2.files_after, ignore=['build']).values() [{}, {}, {}] -Uninstall an easy_installed package:: +Uninstall an easy_installed package with scripts:: >>> reset_env() >>> env = get_env() - >>> result = env.run(join(env.base_path, 'bin', 'easy_install'), 'INITools') - >>> assert('INITools' in result.files_updated[easy_install_pth].bytes), result.files_after[easy-install_pth].bytes - >>> result2 = run_pip('uninstall', 'INITools', '-y', expect_error=True) + >>> result = env.run(join(env.base_path, 'bin', 'easy_install'), 'Markdown') + >>> assert('Markdown' in result.files_updated[easy_install_pth].bytes), result.files_after[easy-install_pth].bytes + >>> result2 = run_pip('uninstall', 'markdown', '-y', expect_error=True) >>> diff_states(result.files_before, result2.files_after, ignore=['build']).values() [{}, {}, {}]