Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Refs #640. Normalize a relative egg-link path before checking to see if it matches #641

Open
wants to merge 1 commit into from

5 participants

@kylegibson

No description provided.

@travisbot

This pull request passes (merged a87f259 into 1749343).

@mcdonc

This patch looks great. Do you think you might be able to contribute a test or two to "tests/test_uninstall.py"?

@kylegibson

@mcdonc Yeah I can. Given that this patch depends on behavior of virtualenv after a package has already been installed, is it sufficient enough to just recreate the situation manually (i.e. create an egg-link file that is relative), or do you suggest something else?

@carljm
Owner

@kylegibson The pip tests already create a scratch virtualenv for each test, so you do have the option of actually calling virtualenv --relocatable in the test (there is some code that reuses virtualenvs between tests to speed things up, so you'll want to make sure this one doesn't get reused, I'd have to dig into test_pip.py to recall exactly how that's done). You can either do that or try to accurately reconstruct its effects, whichever you find more straightforward.

@mcdonc
@msabramo

This needed tests which were never added and now it doesn't merge cleanly. I'd say close it.

@msabramo

Unless @kylegibson is interested in updating this to merge cleanly and add tests,
I'd say this can be closed to make the # of outstanding PRs more manageable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 16, 2012
  1. @kylegibson
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 4 deletions.
  1. +14 −4 pip/req.py
View
18 pip/req.py
@@ -469,15 +469,25 @@ def uninstall(self, auto_confirm=False):
paths_to_remove.add_pth(easy_install_pth, './' + easy_install_egg)
elif develop_egg_link:
- # develop egg
+ # read contents of egg link file
fh = open(develop_egg_link, 'r')
- link_pointer = os.path.normcase(fh.readline().strip())
+ path_in_egg_link = os.path.normcase(fh.readline().strip())
fh.close()
+
+ develop_egg_link_dirname = os.path.dirname(develop_egg_link)
+ link_pointer = path_in_egg_link
+ if not link_pointer.startswith('/'):
+ # properly handle relative egg link paths
+ link_pointer = os.path.abspath(
+ os.path.join(develop_egg_link_dirname, link_pointer)
+ )
assert (link_pointer == dist.location), 'Egg-link %s does not match installed location of %s (at %s)' % (link_pointer, self.name, dist.location)
paths_to_remove.add(develop_egg_link)
- easy_install_pth = os.path.join(os.path.dirname(develop_egg_link),
+ easy_install_pth = os.path.join(develop_egg_link_dirname,
'easy-install.pth')
- paths_to_remove.add_pth(easy_install_pth, dist.location)
+ # If the egg link was relative, it will be relative in the
+ # easy_install file as well.
+ paths_to_remove.add_pth(easy_install_pth, path_in_egg_link)
# find distutils scripts= scripts
if dist.has_metadata('scripts') and dist.metadata_isdir('scripts'):
Something went wrong with that request. Please try again.