-
-
Notifications
You must be signed in to change notification settings - Fork 12k
BLD: Windows absolute path DLL loading #13019
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
Conversation
* add an Azure CI test to mimic recent Anaconda DLL path resolution restrictions that prevent NumPy imports * patch numpy.core initialization to use absolute DLL path loading to overcome the scenario described above
|
CI is all green -- I think this is looking like the safer alternative now? |
|
I'm not sure that we need to remove the PATH mangling block in If the DLL is already in memory from the core load I don't see the problem, but maybe just needs to be clarified. It may be ugly to mutate the path, but maybe also something to be said for minimal adjustments to distutils. |
|
I don't think that this is the fix we were discussing? maybe my understanding is wrong - it's hard to keep track of all the issues/discussions. but what I thought was that the generic solution that will work for both numpy and scipy is to keep using also there's this: #10229 (comment) (related to our previous attempt, and my comment above - which seems to not be correct). okay, my conclusion for now is that (a) I need a better summary to not get confused, and (b) this is still a numpy specific fix that doesn't affect scipy and other packages either way. For now it's not clear to me how to best fix |
Not modifying any search path, just loading with the full path to the DLL. His first choice was just copying the DLL right into core. |
|
Yeah, this deliberately tries to avoid distutils. If SciPy needs access to If SciPy decides not to do that (it may be a LOT of |
It starts to look like that's what is needed. Unless the conda change gets reverted or amended to pick up dynamic PATH adjustments, which may still happen. |
* Test for DLL pollution in numpy/.libs/ in Azure CI Windows Python 3.6 builds * emit a warning with DLL names when > 1 are present in numpy/.libs/
|
FYI, since a lot of the relevant people seem to be here, I filed https://bugs.python.org/issue36085 to consider making a potential breaking change in Python 3.8 to help address this. All input is welcome! |
|
The reason I asked to remove the |
|
For both PRs the workflow was like this:
How can either fix not be doing anything if they both restore a working NumPy import though the new Azure test? I don't see how the PATH code plays into any of that. There's a clear negative test result -> positive test result from the changes in isolation. If the PATH code had enough influence to restore access to |
Sorry I missed this part in the changes here. Anyhow, the changes are now not needed so why leave the extra code? |
Just to minimize the impact on |
|
@rgommers et. al. Is this the preferred solution? |
|
Let's give this a shot and see if it stops the bleeding. Thanks Tyler. |
|
I wonder where Anaconda puts the DLLs? |
They don't move them around; DLLs from a package build stay within the package install dir. Of course in this particular case, there is no static linking so the problematic OpenBLAS DLL and gfortran DLL are not shipped with numpy but provided by the Don't have a Windows machine to check, but it's probably the same as on Linux: they end up at |
|
I see two issues with this PR:
|
This was mostly targeted to alleviate a specific scenario where you install from one of our pre-built wheels and then if, like Anaconda temporarily did, you somehow restrict access to numpy/.libs for DLL resolution In fact, I wasn't really targeting builds at all--just the way the files copied from the pre-built wheel behave to resolve DLLs on Windows. The file you mention clearly indicates:
It sounds like distributors are free to do that as they see fit. |
This is a good point, arguably we should move this bit of code to the On second thought: we are anyway going to change to another final solution, so let's not move it to
Hmm, I wasn't aware of that. Looks like we also have a usage of |
Builds from source distribution without a |
Okay, the problem is - there isn't a good alternative. Python is a bit braindead in this case. In many places one can find discussions about There's a Python issue for this: https://bugs.python.org/issue21736 EDIT: in this case, just wrapping in try-except is probably the way to go |
Why? Our wheels aren't used exclusively by conda--how do you target to just conda wheel usage? Another consumer of wheels could make the same argument that they don't brick DLL resolution so we need another layer of abstraction. And the fix isn't just for conda, it just happens to be motivated to relieve the type of scenario they caused. And is it really desirable to introduce dissonance between the dev and wheels workflow this way? It may be possible to dig up other pieces of code that primarily benefit wheels & present a similar argument to generate further dissonance / abstraction. |
|
Re
Re |
This doesn't sound quite right. Admittedly, it's complex and very much under-documented. Conda doesn't use wheels. This code is specific to the wheels that we build with the
Yes, I think you're right. We should not modify the |
If the change is transplanted to the wheels repo, can we pull it in for one of our dev CI runs as well to retain harmony there? There's OpenBLAS thread handling behavior in the core |
that's applicable to other OpenBLAS-based builds too though (should be correct and needed for any user who builds from source against OpenBLAS), not just our
For the record, this is not quite accurate. |
Is that practically true for CPython/Win32 from python.org (not msys, WSL, cygwin, Anaconda)? I have a dozen versions of MKL, BLIS, OpenBLAS, LAPACK headers and libraries on my Windows system, but |
|
Probably not - a number of standard locations are searched, but I'm not sure if those are reasonable on Windows.
We try to encourage users to use a distribution rather than python.org installers, because those installers are a recipe for disaster unless you know exactly what you're doing. So Python.org Python isn't default or special anymore, it's just one of many options. |
Alternative to #12994
As discussed in #12667 by @rgommers, this may have the advantage of not bricking SciPy / ecosystem projects since it confines the "guaranteed" openblas-related DLL load to numpy/core instead of the distutils machinery change.