Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uninstall: remove symlinks created by flit install --symlink #6914

Merged
merged 5 commits into from
Sep 18, 2019

Conversation

sbidoul
Copy link
Member

@sbidoul sbidoul commented Aug 23, 2019

Fixes #6892

This PR adds a failing test and a fix for uninstalling in a scenario that is very close to what flit install --symlink does.

The fix has two parts:

  • avoid a redundant path normalization in is_local that was defeating careful head normalization in req_uninstall.py.
  • avoid accidentally changing permission of the symlink target by considering symlinks as files instead of directories in StashedUninstallPathSet

@sbidoul sbidoul force-pushed the pip6892-sbi branch 2 times, most recently from fb55f10 to cbf3e9c Compare August 24, 2019 09:43
@sbidoul
Copy link
Member Author

sbidoul commented Aug 24, 2019

@cjerdonek thanks for the review. Simplification done.

@cjerdonek
Copy link
Member

@sbidoul Thanks for the updates. Re: your comment here on the original issue:

But it reveals another issue: when uninstalling such symlinks, pip ends up modifying the permissions on the target directory to 0200...

Can you point out whether / how this PR addresses that? Is a code comment warranted if this was an issue that went unnoticed in the past?

@sbidoul
Copy link
Member Author

sbidoul commented Aug 24, 2019

@cjerdonek I just extracted the part concerning stash/commit/rollback of symlinks in a separate commit and added extensive tests.

There is also an integration test for the mode change:

assert symlink_target.stat().st_mode == st_mode

@cjerdonek
Copy link
Member

Sorry, I didn't mean to suggest this PR should (or needed) to address that comment. I was just asking because I wasn't sure. Does the second fix have to go with the first fix? In other words, would it cause problems if only the first part was done? If not, I think it would be better to do the second part as a separate issue and PR because it seems like a distinct issue and would make it easier to understand and review.

@sbidoul
Copy link
Member Author

sbidoul commented Aug 25, 2019

I think both should be addressed together. Before this PR, uninstalling was merely leaving symlinks behind in the virtualenv. With the first part of this PR, the symlinks get removed but the stash mechanism corrupts the symlink targets. So I think only merging the first part would make the situation worse and it's best to fix the stashing mechanism at the same time.

Is the separate commit sufficient to facilitate review or do you prefer a separate PR and merge them together?

@sbidoul
Copy link
Member Author

sbidoul commented Aug 25, 2019

Also, the test for part 2 needs improvements in tests/lib/path.py that are in part one. So splitting the PR is somewhat more complicated.

@cjerdonek
Copy link
Member

So I think only merging the first part would make the situation worse and it's best to fix the stashing mechanism at the same time.

Okay, this is good to know then. Before you had proposed only the first part without mentioning that more work needed to be done.

Is the separate commit sufficient to facilitate review or do you prefer a separate PR and merge them together?

If both parts need to be committed together, then it should be one PR.

@@ -427,10 +427,12 @@ def is_local(path):

If we're not in a virtualenv, all paths are considered "local."

Caution: this function assumes the head of path has been normalized
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just normalize the head of path here and below?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but I think the callers need to do it too anyway, so for the use cases we have it would be redundant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better redundant and give a consistent interface with no gotchas IMO, but I won't block this on this point.

Copy link
Member

@chrahunt chrahunt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@chrahunt chrahunt merged commit b1bc41b into pypa:master Sep 18, 2019
@chrahunt
Copy link
Member

Thanks!

@sbidoul sbidoul deleted the pip6892-sbi branch September 23, 2019 09:06
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Oct 23, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pip uninstall does not remove symlinks created by flit install --symlink
3 participants