1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

fix uninstall of namespaced packages (fixes #34)

This commit is contained in:
Carl Meyer 2009-12-04 13:18:21 -05:00
parent 2770524365
commit 148ff3a8ed
3 changed files with 27 additions and 14 deletions

View file

@ -4,6 +4,8 @@ News for pip
hg tip
------
* Fixed uninstallation of distributions with namespace packages.
* Added support for the ``https`` and ``http-static`` schemes to the
Mercurial and ``ftp`` scheme to the Bazaar backend.

View file

@ -393,19 +393,19 @@ execfile(__file__)
if dist.has_metadata('installed-files.txt'):
for installed_file in dist.get_metadata('installed-files.txt').splitlines():
path = os.path.normpath(os.path.join(pip_egg_info_path, installed_file))
if os.path.exists(path):
paths_to_remove.add(path)
paths_to_remove.add(path)
if dist.has_metadata('top_level.txt'):
if dist.has_metadata('namespace_packages.txt'):
namespaces = dist.get_metadata('namespace_packages.txt')
else:
namespaces = []
for top_level_pkg in [p for p
in dist.get_metadata('top_level.txt').splitlines()
if p]:
if p and p not in namespaces]:
path = os.path.join(dist.location, top_level_pkg)
if os.path.exists(path):
paths_to_remove.add(path)
elif os.path.exists(path + '.py'):
paths_to_remove.add(path + '.py')
if os.path.exists(path + '.pyc'):
paths_to_remove.add(path + '.pyc')
paths_to_remove.add(path)
paths_to_remove.add(path + '.py')
paths_to_remove.add(path + '.pyc')
elif dist.location.endswith(easy_install_egg):
# package installed by easy_install

View file

@ -3,13 +3,14 @@ Basic setup::
>>> from __main__ import here, reset_env, run_pip, pyversion, lib_py, get_env, diff_states, write_file
>>> from os.path import join
>>> from tempfile import mkdtemp
>>> easy_install_pth = join(lib_py, 'site-packages', 'easy-install.pth')
>>> site_pkg = join(lib_py, 'site-packages')
>>> easy_install_pth = join(site_pkg, 'easy-install.pth')
Simple install and uninstall::
>>> reset_env()
>>> result = run_pip('install', 'INITools==0.2', expect_error=True)
>>> assert join(lib_py + 'site-packages', 'initools') in result.files_created, sorted(result.files_created.keys())
>>> assert join(site_pkg, 'initools') in result.files_created, sorted(result.files_created.keys())
>>> result2 = run_pip('uninstall', 'INITools', '-y', expect_error=True)
>>> diff_states(result.files_before, result2.files_after, ignore=['build']).values()
[{}, {}, {}]
@ -19,11 +20,21 @@ Uninstall an easy_installed package with scripts::
>>> reset_env()
>>> env = get_env()
>>> result = env.run(join(env.base_path, 'bin', 'easy_install'), 'PyLogo')
>>> assert('PyLogo' in result.files_updated[easy_install_pth].bytes), result.files_after[easy-install_pth].bytes
>>> assert('PyLogo' in result.files_updated[easy_install_pth].bytes), result.files_after[easy_install_pth].bytes
>>> result2 = run_pip('uninstall', 'pylogo', '-y', expect_error=True)
>>> diff_states(result.files_before, result2.files_after, ignore=['build']).values()
[{}, {}, {}]
Uninstall a distribution with a namespace package without clobbering
the namespace and everything in it::
>>> reset_env()
>>> result = run_pip('install', 'pd.requires==0.0.3', expect_error=True)
>>> assert join(site_pkg, 'pd') in result.files_created, sorted(result.files_created.keys())
>>> result2 = run_pip('uninstall', 'pd.find', '-y', expect_error=True)
>>> assert join(site_pkg, 'pd') not in result2.files_deleted, sorted(result2.files_deleted.keys())
>>> assert join(site_pkg, 'pd', 'find') in result2.files_deleted, sorted(result2.files_deleted.keys())
Uninstall a package with more files (script entry points, extra directories)::
>>> reset_env()
@ -46,7 +57,7 @@ Uninstall an editable installation from svn::
>>> reset_env()
>>> result = run_pip('install', '-e', 'svn+http://svn.colorstudy.com/INITools/trunk#egg=initools-dev', expect_error=True)
>>> egg_link = result.files_created[lib_py + 'site-packages/INITools.egg-link']
>>> egg_link = result.files_created[join(site_pkg, 'INITools.egg-link')]
>>> result2 = run_pip('uninstall', '-y', 'initools', expect_error=True)
>>> assert ('src/initools' in result2.files_after), 'oh noes, pip deleted my sources!'
>>> diff_states(result.files_before, result2.files_after, ignore=['src/initools', 'build']).values()
@ -58,7 +69,7 @@ Editable install from existing source outside the venv::
>>> tmpdir = mkdtemp()
>>> result = env.run('hg', 'clone', 'http://bitbucket.org/ianb/virtualenv/', tmpdir)
>>> result2 = run_pip('install', '-e', tmpdir)
>>> assert (join(lib_py, 'site-packages', 'virtualenv.egg-link') in result2.files_created), result2.files_created.keys()
>>> assert (join(site_pkg, 'virtualenv.egg-link') in result2.files_created), result2.files_created.keys()
>>> result3 = run_pip('uninstall', '-y', 'virtualenv', expect_error=True)
>>> diff_states(result.files_before, result3.files_after, ignore=['build']).values()
[{}, {}, {}]