-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
warn before overwriting files owned by previously installed wheels #8119
Conversation
e864d31
to
c03530d
Compare
The Windows tests are failing because they're seeing a deprecation warning for python 2.7 instead of the new warning about the conflicting file. Should that test be marked python 3 only? The Travis job seems to have failed with an error for PyPI.org. I can push a trivial change to rerun those, but maybe if someone has time to give meaningful feedback there's some other real change to be made so I'll hold off. |
They should see both the deprecation warning and the conflicting file. This likely indicates a bug in the implementation. |
5d66c75
to
bf7b22b
Compare
Yes, you’re right. That’s fixed now. |
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
bf7b22b
to
7a2abf4
Compare
rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor comments, more about communication around the change rather than the change itself.
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
7a2abf4
to
f45a974
Compare
Rebased and comments addressed |
f45a974
to
c8d819f
Compare
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
Hi there, I've just noticed the nice |
I used a sequence argument because I expected the input to come from splitting inputs or filtering some other sequence and have an unknown number of values. The passing a single such value to a function, rather than exploding it to use a variadic calling pattern, seemed like the right fit. Did you have a different sort of use case in mind? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks basically good to go -- could you rebase this + (optionally) make a small change to the tests?
That's right, I was thinking about manual call but it doesn't make much sense for me anymore after reading this 😄 |
c8d819f
to
2dae22b
Compare
3396da0
to
ace9b21
Compare
I get completely different results when I run the linter locally (lots more errors, in unrelated files). Is there some trick to running it beyond using |
I just run that, but my |
is reported and that the second wheel does overwrite | ||
the first. | ||
""" | ||
from tests.lib import TestFailure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a few other tests in this file importing this inside the test. Maybe it's a good time to move this import along with the others at the top?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just following the local coding patterns in this PR. Changing all of that seems like a task for another PR.
I have tox in a virtualenv, too.
https://gist.github.com/dhellmann/4bba77827a56e6890f5e3633153f5153 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we take a slightly different approach, like:
- pre-compute a list of the paths that will be installed for the current wheel, from the files in the source directory and the anticipated generated script files (this would be easier with some refactoring, which could be done in separate PRs ahead-of-time)
- if any file already exists, then determine what package owns it using
RECORD
orinstalled_files.txt
for the installed packages in the environment - report the conflict as a warning, after filtering out
__init__.py
associated with namespace packages, as mentioned in the original issue
This has several benefits:
- 1 will be mostly compatible with installation directly from wheel (see Extract wheels directly to install location #6030)
- 1 also covers generated script files
- 2 should be compatible with more distributions and have fewer false negatives than looking at
top_level.txt
(which I believe is non-standard) - doing 2 lazily (when we see a file which will be overwritten) means in the majority of cases we will not need to process every installed package
with open(installing_top_level_path, 'r') as fd: | ||
installing_top_level = fd.read().strip() | ||
files_from_other_owners = _get_file_owners( | ||
lib_dir, installing_top_level, name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it should be necessary to ignore the installing package, since we should have uninstalled the existing distribution before trying to install a new version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually a file conflict will be an error that prevents installation. We want to report the error before removing the existing version and breaking the environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We currently have a rollback mechanism that reverts an upgrading package on any installation failure. I think this should have us covered, if I understand the concern you're raising.
Before installing a wheel, look for other distributions that have also written files into the same top level directory. Warn if any of the same files will be modified by the new wheel. Addresses pypa#4625 Signed-off-by: Doug Hellmann <[email protected]>
Signed-off-by: Doug Hellmann <[email protected]>
Rather than emitting a separate warning for each owner, produce one warning with all of the other owner names in the message. Signed-off-by: Doug Hellmann <[email protected]>
7bb5beb
to
cca8cfb
Compare
Can you describe how the approach that has already been implemented is incompatible with installing directly?
Yes, that's a shortcoming of this implementation. It's still an incremental improvement.
Is it? It's in all of the installed packages I see on my system and it's there in the test suite when the test wheels are installed. What's creating it?
If we're going to turn this into a blocking error, we need to examine the state of the system before making changes. To handle the upgrade case, we need to look for conflicts while we may have an old version of the package installed, which would automatically trigger looking for the owner of (effectively) every file that would be installed. So I don't think we would buy much time by doing the ownership evaluation lazily in a lot of cases. The current implementation only looks at distributions that claim to have written files to the same top level directory as the one being installed, so it ignores most of them already. |
|
So I guess to be accurate this would need to read the |
Yes. Since pip itself generates
Yes, that should be OK! A few things that may help:
|
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
There have been other (valid) concerns raised that I agree with. :)
Before installing a wheel, look for other distributions that have also
written files into the same top level directory. Warn if any of the
same files will be modified by the new wheel.
Addresses #4625