Conversation
|
This change makes $ .tox/py35/bin/pip uninstall nose
Uninstalling nose-1.3.7:
/home/pradyunsg/code/pip/.tox/py35/bin/nosetests
/home/pradyunsg/code/pip/.tox/py35/bin/nosetests-3.4
/home/pradyunsg/code/pip/.tox/py35/lib/python3.5/site-packages/nose-1.3.7.dist-info/*
/home/pradyunsg/code/pip/.tox/py35/lib/python3.5/site-packages/nose/*
/home/pradyunsg/code/pip/.tox/py35/man/man1/nosetests.1
Proceed (y/n)? y
Successfully uninstalled nose-1.3.7The listing of all the files (as currently given by # I manually inserted the [snip] to prevent an overly long message
$ .tox/py35/bin/pip uninstall --verbose nose
Uninstalling nose-1.3.7:
/home/pradyunsg/code/pip/.tox/py35/bin/nosetests
/home/pradyunsg/code/pip/.tox/py35/bin/nosetests-3.4
/home/pradyunsg/code/pip/.tox/py35/lib/python3.5/site-packages/nose-1.3.7.dist-info/DESCRIPTION.rst
[snip]
/home/pradyunsg/code/pip/.tox/py35/lib/python3.5/site-packages/nose/usage.txt
/home/pradyunsg/code/pip/.tox/py35/lib/python3.5/site-packages/nose/util.py
/home/pradyunsg/code/pip/.tox/py35/man/man1/nosetests.1
Proceed (y/n)? y
Removing file or directory /home/pradyunsg/code/pip/.tox/py35/bin/nosetests
Removing file or directory /home/pradyunsg/code/pip/.tox/py35/bin/nosetests-3.4
Removing file or directory /home/pradyunsg/code/pip/.tox/py35/lib/python3.5/site-packages/nose-1.3.7.dist-info/DESCRIPTION.rst
[snip]
Removing file or directory /home/pradyunsg/code/pip/.tox/py35/lib/python3.5/site-packages/nose/usage.txt
Removing file or directory /home/pradyunsg/code/pip/.tox/py35/lib/python3.5/site-packages/nose/util.py
Removing file or directory /home/pradyunsg/code/pip/.tox/py35/man/man1/nosetests.1
Successfully uninstalled nose-1.3.7(edited to add descriptions to the runs) |
|
Your comment is a bit confusing. I assume the first output is the new shorter version, and the one with One question - if there's something in I know it's an extremely unlikely case, so I'm not going to make a major issue out of it if no-one else thinks it's important, but I don't like the thought that we say we're going to delete |
Yeah... That is the output of uninstall command from this PR. Without
It would still show it and not delete that file... I didn't think of that. I thought along the lines of what folders does a package "own" all files of, how to determine those paths and came up with this.
Same but then, how do you think we should show the output then? I can't come up with something terse yet clean way of displaying this situation. |
|
I think that's the problem here. There isn't a clean way to display that. Also there's the I don't have a good solution here. For a completely quiet uninstall, there's the I guess we could add a section after the file list if there are any unexpected files, just before the "Are you sure?" prompt: But I suspect it'll be significantly more complex to collect that information. What do you think? |
| new_paths = [] | ||
| for path in paths: | ||
| if path.endswith("__init__.py"): | ||
| new_paths.append(path[:-12] + os.path.sep + "*") |
There was a problem hiding this comment.
os.path.dirname would be cleaner :o
| path[len(shortpath.rstrip("*").rstrip(sep))] == sep | ||
| for shortpath in short_paths | ||
| ) | ||
| if not should_add: |
There was a problem hiding this comment.
Maybe we should "just" enhance compact to detect the case where it has:
['a/b/toto.py', 'a/b/tutu.py'] and 'a/b' only contains the two files, then it should only keep 'a/b'
This should produce a much more compact output in most cases.
There was a problem hiding this comment.
That's what I did initially but these same paths are being used to delete files and I didn't want to modify this logic because of that.
There was a problem hiding this comment.
That sounds reasonable. If there are still cases where it's not compact enough, we can review those to work out what additional improvements are practical and safe. (We may need to special-case __pycache__, although https://github.com/pypa/pip/blob/master/pip/req/req_uninstall.py#L115 might cover it)
There was a problem hiding this comment.
@pfmoore I added checks to filter out for .pyc files locally in the non-verbose mode.
|
I'm gonna grab lunch now. I think I'll just refactor out the user interaction/output code into a separate function. And do all the processing for what to show within that. |
I think it looks good. |
|
Non-Verbose mode output now mentions which files would not be removed. Verbose mode output stays the same. |
|
@pfmoore @xavfernandez Do any of you think it'll be useful to add which files would not be removed to the verbose output? I think it'll be useful there. :) |
pip does list them in the output.
I think that doing what we said we would - uninstall the package - is what we do. If the user uses |
Now, after a sleep cycle, I don't think so. :/ |
What I'm getting at is that if the user doesn't specify If the user says to proceed then they are entitled to assume that the whole of With the addition of the extra information it's fine, because we've explicitly said that we're going to leave some files behind. I'm perfectly OK with the fact that if the user specified |
Files are not listed if you specify
The PR does this now. See #4493 (comment) |
|
I think this is ready. /request-review @dstufft @pfmoore @xavfernandez |
| file_ = os.path.join(dirpath, fname) | ||
| if os.path.isfile(file_) and file_ not in files: | ||
| # We are skipping this file. Add it to the set. | ||
| will_skip.add(file_) |
There was a problem hiding this comment.
@pradyunsg Ideally this logic should be extracted in a function with a few simple tests
There was a problem hiding this comment.
I was thinking unittest to test that given a long list of files we do end up with the correct shorter list.
|
@pfmoore Cool. I think I understand it now -- it's just the matter of running things through |
|
It usually is :-) ("Just scatter normcase around" is the new version, in a post-Unicode world, of "just add a few encode/decode calls" 😃 ) |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Closes #4229