Skip to content

Commit

Permalink
MAINT: probe multiple DLL handling on Win
Browse files Browse the repository at this point in the history
* 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/
  • Loading branch information
tylerjereddy committed Feb 22, 2019
1 parent 468539a commit 922507b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ jobs:
pip install $_.FullName
}
displayName: 'Build NumPy'
- bash: |
pushd . && cd .. && target=$(python -c "import numpy, os; print(os.path.abspath(os.path.join(os.path.dirname(numpy.__file__), '.libs')))") && popd
pip download -d destination --only-binary --no-deps numpy==1.14
cd destination && unzip numpy*.whl && cp numpy/.libs/*.dll $target
ls $target
displayName: 'Add extraneous & older DLL to numpy/.libs to probe DLL handling robustness'
condition: eq(variables['PYTHON_VERSION'], '3.6')
- script: pushd . && cd .. && python -c "from ctypes import windll; windll.kernel32.SetDefaultDllDirectories(0x00000800); import numpy" && popd
displayName: 'For gh-12667; Windows DLL resolution'
- script: python runtests.py -n --show-build-log --mode=$(TEST_MODE) -- -rsx --junitxml=junit/test-results.xml
Expand Down
8 changes: 8 additions & 0 deletions numpy/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@
# convention for storing / loading the DLL from
# numpy/.libs/, if present
libs_path = Path(Path(__file__).absolute().parents[1], '.libs')
DLL_filenames = []
if libs_path.exists():
for filename in libs_path.glob('*openblas*dll'):
# NOTE: would it change behavior to load ALL
# DLLs at this path vs. the name restriction?
WinDLL(str(filename.absolute()))
DLL_filenames.append(str(filename))
if len(DLL_filenames) > 1:
import warnings
warnings.warn("loaded more than 1 DLL from .libs:",
stacklevel=1)
for DLL_filename in DLL_filenames:
warnings.warn(DLL_filename, stacklevel=1)

# disables OpenBLAS affinity setting of the main thread that limits
# python threads or processes to one core
Expand Down

0 comments on commit 922507b

Please sign in to comment.