-
-
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
Prefer included distutils even without importing setuptools. Closes #2259. #2305
Conversation
With the new `.pth` file, these warnings are no longer necessary.
This puts non-distutils imports first and removes one unused import.
This reverts commit 30b883f.
…e. Generate distutils-precedence.pth inline.
…an just an importer.
… and advise against copying of the behavior.
…enabled' logic is duplicated in pth file).
Per my comments in #2260, I strongly disagree with this course of action. I don't think we should move forward with this change without testing, and even if we did, I think we should at least clean up the history so it's easier to revert specific subsets of the changes if necessary. |
I very much respect your opinion @pganssle, so I'm going to take another stab at writing a suite of tests for the distutils expectation. |
I observe that the tests are failing on Windows, even though I thought they were passing in the previous PR. The test failures are in |
The error occurs when it tries to run
It seems the |
Here are the values of install_lib and install_libbase during the execution:
|
Weird - I notice that suffix has no space at the end:
But when I run it locally, I get a different result:
|
b1a9dd7
to
74420c9
Compare
199d1ac
to
521987d
Compare
Well, that's annoying. The pypy3 tests on macOS only are failing the new test. I guess that's expected, since we know pypy imports stdlib distutils on startup. |
Hmm, is that because it imports distutils before the pth file is executed? |
That's right.
If I recall correctly (low confidence), pypy for Python 3.7 no longer has this issue. But here's something weird:
I thought the only thing |
TIL:
|
|
It's the calling of
|
Right - now I remember:
|
It does appear that even on the unreleased PyPy for Python 3.7 still imports distutils early. |
Perhaps there are some optimizations or tweaks we can make for PyPy, but for now, I'd prefer to push forward with this approach. |
Released as 49.3.0 |
This PR shouldn't have closed the issue. The issue is not fixed and manifests just as it did before. It's now only able to be bypassed by setting an environment variable. So to fix it still requires me an arbitrary environment variable change in my code... |
Thanks Bernát, though I'm not sure I follow. #2259 reported an issue that when the new distutils is included, it only works when setuptools is imported prior to importing distutils. This patch fixed that condition. #2259 was not about ensuring that distutils was preferred in all environments, though that's still a goal. I have added new issues to the milestone to capture ongoing efforts. If that doesn't capture the missed use-cases, please elaborate. |
Summary of changes
In #2259, Paul outlines the problem - users that import distutils before importing setuptools, a common if not recommended practice, will receive a warning and will end up with objects from different implementations of distutils.
When enabled, this change installs a .pth file (except for editable installs of setuptools) to the user's environment to ensure that the setuptools-provided distutils is preferred before setuptools has been imported (and even if setuptools is never imported).
This feature relies on the same SETUPTOOLS_USE_DISTUTILS flag for opt-in now and opt-out in the future (set to "local" for opt-in and "stdlib" for opt-out).
This patch was originally submitted as #2260 but backs out the refactoring that left the implementation in an unsuitable state.
Pull Request Checklist