-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Reconsidering distutils replacement strategy #2259
Comments
I was thinking of something similar:
This approach has a bit less indirection and would be less susceptible to issues with path manipulation (platform-specific path separators, interactions with alternate importers such as zipimporter). This approach also allows |
@jaraco Wouldn't The approach I've taken in #2260 probably won't work with |
Good point.
Is that an acceptable limitation? I suspect not. |
It's certainly not ideal. I think we should do our best to support whatever environments people are running That said, I'm not sure what the use cases are where people are running |
Another approach to consider:
|
Ref: pypa/setuptools#2259 git-svn-id: file:///srv/repos/svn-community/svn@664246 9fca08f4-af9d-4005-b8df-a31f2cc04f65
It seems you released setuptools 49.2.1 without resolving this issue (also #2260). Was that on purpose? This is causing no end of problems with downstream projects, and will slow the adoption of new versions of setuptools. |
Yes. #2260 is blocked on a rewrite and request/need for more sophistication in the solution. 49.2.1 fixed the thing that it fixed. I agree this issue is important and I'd like to get it addressed asap. |
Thanks for the fix. However, I noticed that the warning is still raised in setuptools 49.3.0
Is the warning expected in the new |
Hmm. Yeah, that's a little annoying, but somewhat intentional. The pth behavior is only enabled when
I'd like 49.3 to prove stable then switch the default (so |
Got it, thanks for clarification! |
This is getting really frustrating. It's now the third setutpools release that breaks multiple CIs of mine only because some libraries dare to use Also, please don't close an issue until it's not fixed. This clearly isn't, not at least the default switch is the other way around. |
Yes this is clearly not fixed until the now hopefully pointless warning is removed. |
Why would this be intentional? The point of the other fix is so that you wouldn't care about the import order except in very rare situations. I originally removed it entirely, but ended up putting it back in place to point at the problem if the pth file wasn't working properly. It makes no sense to raise the warning if you aren't even doing the distutils replacement. |
It's intentional because the distutils replacement is currently opt-in. Maybe the warning should only be present if the distutils replacement is opted in. If we are encouraging packagers to import distutils late or not to import it at all, the argument can be made that the warning should be issued unconditionally, as it's still preferable for a packager to present the most compatible interface, even if a particular environment doesn't have the future features enabled. My instinct is to push forward with making the distutils replacement opt-out (#2255). I'm open to tweaking the warnings too. |
If we want people to stop importing The only real purpose of the warning is to let people know that we have replaced |
I disabled this warning except in cases where the distutils import is enabled in #2316, and I've pushed out a v49.3.1 release (which should hit PyPI in an hour or so when the tests pass, I guess). |
I first expressed concerns about the fact that
distutils
needs to be imported aftersetuptools
in this post, and I did not realize that we had not adequately addressed this before thedistutils
adoption. I think we should re-consider the way this is done, to avoid any sort of requirement on the sort order.Currently, when you
import setuptools
,distutils
is injected intosys.modules
.The problem here is that it requires importing
setuptools
beforedistutils
, which most people will not be doing right now (by almost all common import sort orders,distutils
comes first).@jaraco explains why it's done this way here:
I think one preferred solution would be for us to install a
distutils
package that would be imported beforedistutils
. The problem is that in the standardsys.path
,site-packages
comes after the standard library. Since anything we do here will be a tremendous hack, I'm thinking that maybe the most surgical way to accomplish this is to do something like this:setuptools._distutils/import_hack/distutils/__init__.py
(where there's no__init__.py
inimport_hack
) that invokesimport setuptools.distutils_patch
..pth
file that injects$SITEPACKAGES/setuptools/_import_hack/
intosys.path
before the standard library.Another option I think we should consider is stepping up the timetable on providing everything
distutils
provides directly from thesetuptools
namespace, as I described here:Right now, there are things that you must import from
distutils
, and so we can't say, "You can avoid an issue with the sort order by just not importingdistutils
". If we provide everything thatdistutils
provides in thesetuptools
namespace, we can just say, "Just use thesetuptools
version and you won't have this problem."Personally, I think we should do a combination of both — make it so importing
distutils
still works in whatever order you do it in and move everything to the canonicalsetuptools
namespace. That will make it easier to actively deprecate direct use ofdistutils
, and pave the way for us eventually removing the need for the.pth
file (though the fastest road to not having the.pth
file will be via removingdistutils
from the standard library).The text was updated successfully, but these errors were encountered: