Adjust win path/dll path lookup mechanism
Overview
In the init.py, adjust win specific path to use .add dll path when that function is available in the underlying python c-api.
The issue is a bit involved, since it appears that there is a lot of preconditions that needs to click in for this to work, even for fresh versions of python (e.g. change was added in py 3.8, but we are running test on py 3.9).
Some info can be found here:
conda trouble shooting dll hell
which is referenced in a rather large number of stack overflow questions.
This is consistent with our own experience in shyft at the time when conda/py 3.8 was released, most external packages started breaking in any possible manner on windows.
Also a quick test shows that on win/py 3.9, just replacing traditional PATH extension with the 'theoretically correct' windows specific os.add_dll_directory() simply does not work.
... unless you set
set CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1
prior to starting the script. (tested on 3.9.7.final.0, windows 10)
This indicates that there is a number of tests/preconditions that needs to be meet in order for this to work.
- py >= 3.8.something, or that os.add_dll_directory exists
- the dll search mod is in effect.
otherwise fallback to std path that has been the default mode from early ages on windows, with the limitations that comes from the failed initial shared library design in windows(dll-hell).
We need to know IF the search-mod is enabled, if the env var is the only, then we are safe, but if we are wrong, this will fail on a number of installations.
-
Always add path to env (ignored, or it is part of the success) -
Figure out when to use os.add_dll_directory method (use hasattr(os,"add_dll_directory") ). -
Got it -
Verify it works with/without the new feature enabled