-
-
Notifications
You must be signed in to change notification settings - Fork 293
Remove distutils
path patching
#1321
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d4ded26
Fix ``distutils`` path patching for setuptools >= 60.0.0
DanielNoord 459691a
Remove distutils path thingy
DanielNoord a4115a2
Update astroid/interpreter/_import/spec.py
DanielNoord 69fe5db
Add changelog
DanielNoord 2707f09
Merge branch 'fix-distutils' of https://github.com/DanielNoord/astroiβ¦
DanielNoord 199385e
Add a dot for Marc :)
DanielNoord 917ee0d
Update ChangeLog
DanielNoord File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Tbh I wonder if we should just always use
distutils.__path__
. We do import it earlier, so it's most likely the one we actually want. From what I can tell, the first condition is equal to the else case anyway.Defaulting to the
_distutils
path from setuptools alone can however be dangerous. It was added inv48.0.0
but only became the default inv60.0.0
. So just in theory, if the first condition wouldn't hit, it would pick the wrong path. In that case you probably should add an additional condition to make sure the setuptools distutils is actual the distutils we are using. With that we likely end up with the simplified case from above again.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.
Additionally, just doing
elif spec.name == "distutils"
would remove asetuptools
dependency. -> #1320Maybe we should just test it in production and see if we get any new bug reports π€
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 not completely following you here. Especially with all the latest hot fixes and releases I'm not sure what actually needs to be fixed.
For
pylint
everything seems fine. We might be incompatible withsetuptools~=60.0
but due to all the recent releases it would be quite a big effort to find the specific release which fixed the bug that made thetbump
upgrade fail. I feel like we can let that be, right?For
astroid
this test is still failing forsetuptools==60.2.0
. I agree that the firstif
seems to do the same as theelse
. That can likely be removed, leaving only aif
for_distutils
to be necessary. Do you have any idea how to do thatif
without depending onsetuptools
but being compatible with bothv47
andv60
?Please correct me where I'm wrong. This has been a difficult issue to keep track off and its getting late π
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.
Same π΄ I can try to summarize what I think is going on here.
What do we know?
Starting with
v60
setuptools patches (or better "does some sketchy things") to replace the stdlib version of distutils with their own copy. This is vendored from pypa/distutils and "should" be functionally identical with the stdlib version. If at all, it might include some more bugfixes that won't get included into stdlib.Why?
distuils
has been deprecated and is slated for removal in3.12
. Everyone who is still using it should either switch to thesetuptools
version (or another similar one) or even better replace those function calls altogether. Most, but not all, functions already have equivalents in the stdlib. https://www.python.org/dev/peps/pep-0632/#migration-adviceLongterm, the maintainers of
setuptools
also plan to discontinuedistutils
, but for the meantime it will continue to work.What is actually failing?
As best as I can tell, only the astroid test case. Since the included
distutils
copy is functional identical to the stdlib it doesn't really matter too much that thespec
path points towards thestdlib
while the module is coming fromsetuptools._distutils
.What failed previously?
I only have an educated guess here. There seems to be a habit among certain packages to ship with their own version of distutils. In particular a (presumably old) version of virtualenv seem to have done so. It seems
astroid
had inferred the virtualenv version asspec.location
instead of the stdlib one. That causedImportErrors
as the virtualenv version wasn't a complete copy.Is that still an issue?
I don't know π€·π»ββοΈ
What should the goal here be for
astroid
?Pylint shouldn't report a false-positive
ImportError
for things likedistutils.util
.What path for
distutils
should astroid return?I'm uncertain about this one. If the goal is to prevent the false-positive and enable inference, any "good" copy of
distutils
would probably work. It doesn't really matter too much if it's the one from the stdlib or setuptools, since I don't think the main interface is going to change.What do we do now?
Some options
distutils.__path__
, we could use a good python file to find the stdlib location and built the expected stdlib distutils path from there.distutils
and another time fromsetuptools._distutils
. If both match, we choose to use the setuptools one for the path. Although probably the "most correct one", it requires us to do an expensive import twice.distutils
and see if we get any bug reports. I suspect / hope not but if we do, we at least would know what needs fixing.Is the first conditional for distutils still needed?
π€·π»ββοΈ
My preference?
I believe all of the 4 options above should work. If we don't want to risk it all with (4), option (2) might be an idea. We can always come back to it in case we start getting bug reports eventually.
Did I miss something?
Likely π At this point I don't even know if I've fully understood what's going on. It's also much too late to be writing such long posts π΄