Skip to content
This repository was archived by the owner on Feb 15, 2023. It is now read-only.

Commit e0d7ef2

Browse files
authored
MAINT: init file and mpl updates (#70)
* MAINT: init file and mpl updates * we've been getting reports of new Python 3.7 patch releases from Windows store causing SciPy DLL load issues: scipy/scipy#11826 * so, extend the `_distributor_init.py` machinery usage to include Python 3.7 and up for our wheels * simplify the appveyor `matplotlib` install now that there are stable releases available for Python `3.8` * MAINT: update .travis.yml * fix warnings in `.travis.yml` based on feedback from https://config.travis-ci.com/explore * bump distro to `bionic` since NumPy did this recently too * attempting to restore Travis CI runs to our wheels build matrix * MAINT: revise PR 70 * try using `[System.Version]` for more robust Python version comparisons in powershell * MAINT: PR 70 revisions * update minimum NumPy version to `1.14.5` * the distutils override for appveyor/Windows builds now only happens for Python < 3.7, since we have now added the `_distributor_init.py` for Python 3.7 (not just Python 3.8) * DEBUG: try newer NumPy * try using newer NumPy version for Windows Python 3.7 builds, to see if this helps `check_installed_package.py` * Add debug prints to _distributor_init.py * Debug print contents of .libs path for DLLs * Make sure libs_path exists before trying to debug print contents. * DEBUG: simplify CI matrix for iteration. * DEBUG: more debug prints near point of 32-bit Python 3.7 DLL resolution failure. * DEBUG: try moving into DLL dir * try to solve DLL resolution issues for older (32-bit) Python versions by temporarily moving into the path where they are stored prior to load attempts in `_distributor_init.py` * Revert "DEBUG: simplify CI matrix for iteration." This reverts commit 46e69e1. * MAINT: PR 70 cleanup * remove some debug prints * revert some debug changes * use `_distributor_init.py` with Python 3.6+ (all supported Python versions) * MAINT: PR 70 revisions * wrap the `_distributor_init.py` `os.chdir` code in a `try .. finally` block to ensure restoration of the working directory if something fails * substantially expand the comments describing the rationale for the working directory changes in `_distributor_init.py` * MAINT: PR 70 revisions * sync multibuild submodule to latest `devel` branch checkout in attempt to deal with Travis CI failures that just started appearing
1 parent 9da5817 commit e0d7ef2

File tree

4 files changed

+63
-38
lines changed

4 files changed

+63
-38
lines changed

.travis.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ env:
44
# Also see DAILY_COMMIT below
55
- BUILD_COMMIT=master
66
- PLAT=x86_64
7-
- NP_BUILD_DEP="numpy==1.13.3"
7+
- NP_BUILD_DEP="numpy==1.14.5"
88
- CYTHON_BUILD_DEP="Cython==0.29.14"
99
- PYBIND11_BUILD_DEP="pybind11==2.4.3"
10-
- NP_TEST_DEP="numpy==1.13.3"
10+
- NP_TEST_DEP="numpy==1.14.5"
1111
- UNICODE_WIDTH=32
1212
- MANYLINUX_URL="https://5cf40426d9f06eb7461d-6fe47d9331aba7cd62fc36c7196769e4.ssl.cf2.rackcdn.com"
1313
- WHEELHOUSE_UPLOADER_USERNAME=travis-worker
@@ -19,28 +19,26 @@ env:
1919
- DAILY_COMMIT=master
2020

2121
language: python
22-
# Default Python version is usually 2.7
23-
python: 3.5
24-
sudo: required
25-
dist: trusty
22+
dist: bionic
2623
services: docker
24+
os: linux
2725

28-
matrix:
26+
jobs:
2927
exclude:
3028
# Exclude the default Python 3.5 build
3129
- python: 3.5
3230
include:
3331
- os: linux
3432
env:
3533
- MB_PYTHON_VERSION=3.6
36-
- NP_BUILD_DEP=numpy==1.13.3
37-
- NP_TEST_DEP=numpy==1.13.3
34+
- NP_BUILD_DEP=numpy==1.14.5
35+
- NP_TEST_DEP=numpy==1.14.5
3836
- os: linux
3937
env:
4038
- MB_PYTHON_VERSION=3.6
4139
- PLAT=i686
42-
- NP_BUILD_DEP=numpy==1.13.3
43-
- NP_TEST_DEP=numpy==1.13.3
40+
- NP_BUILD_DEP=numpy==1.14.5
41+
- NP_TEST_DEP=numpy==1.14.5
4442
- os: linux
4543
env:
4644
- MB_PYTHON_VERSION=3.7
@@ -71,8 +69,8 @@ matrix:
7169
language: generic
7270
env:
7371
- MB_PYTHON_VERSION=3.6
74-
- NP_BUILD_DEP=numpy==1.13.3
75-
- NP_TEST_DEP=numpy==1.13.3
72+
- NP_BUILD_DEP=numpy==1.14.5
73+
- NP_TEST_DEP=numpy==1.14.5
7674
- os: osx
7775
language: generic
7876
env:

_distributor_init.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,42 @@
2222
libs_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
2323
'.libs'))
2424
if os.path.isdir(libs_path):
25-
for filename in glob.glob(os.path.join(libs_path, '*dll')):
26-
WinDLL(os.path.abspath(filename))
25+
# for Python >= 3.8, DLL resolution ignores the PATH variable
26+
# and the current working directory; see release notes:
27+
# https://docs.python.org/3/whatsnew/3.8.html#bpo-36085-whatsnew
28+
# Only the system paths, the directory containing the DLL, and
29+
# directories added with add_dll_directory() are searched for
30+
# load-time dependencies with Python >= 3.8
31+
32+
# this module was originally added to support DLL resolution in
33+
# Python 3.8 because of the changes described above--providing the
34+
# absolute paths to the DLLs allowed for proper resolution/loading
35+
36+
# however, we also started to receive reports of problems with DLL
37+
# resolution with Python 3.7 that were sometimes alleviated with
38+
# inclusion of the _distributor_init.py module; see SciPy main
39+
# repo gh-11826
40+
41+
# we noticed in scipy-wheels repo gh-70 that inclusion of
42+
# _distributor_init.py in 32-bit wheels for Python 3.7 resulted
43+
# in failures in DLL resolution (64-bit 3.7 did not)
44+
# as a result, we decided to combine both the old (working directory)
45+
# and new (absolute path to DLL location) DLL resolution mechanisms
46+
# to improve the chances of resolving DLLs across a wider range of
47+
# Python versions
48+
49+
# we did not experiment with manipulating the PATH environment variable
50+
# to include libs_path; it is not immediately clear if this would have
51+
# robustness or security advantages over changing working directories
52+
# as done below
53+
54+
# we should remove the working directory shims when our minimum supported
55+
# Python version is 3.8 and trust the improvements to secure DLL loading
56+
# in the standard lib for Python >= 3.8
57+
try:
58+
owd = os.getcwd()
59+
os.chdir(libs_path)
60+
for filename in glob.glob(os.path.join(libs_path, '*dll')):
61+
WinDLL(os.path.abspath(filename))
62+
finally:
63+
os.chdir(owd)

appveyor.yml

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ environment:
1717
OPENBLAS_32_SHA256: 06e3d38f01119afe5d6630d7ad310a873f8bede52fe71f2d0e2ebf3476194892
1818
OPENBLAS_64_SHA256: 4d496081543c61bfb8069c1a12dfc2c0371cf9c59f9a4488e2e416dd4026357e
1919
CYTHON_BUILD_DEP: Cython==0.29.14
20-
NUMPY_TEST_DEP: numpy==1.13.3
20+
NUMPY_TEST_DEP: numpy==1.14.5
2121
PYBIND11_BUILD_DEP: pybind11==2.4.3
2222
TEST_MODE: fast
2323
APPVEYOR_SAVE_CACHE_ON_ERROR: true
@@ -61,12 +61,12 @@ environment:
6161
- PYTHON: C:\Python36
6262
PYTHON_VERSION: 3.6
6363
PYTHON_ARCH: 32
64-
NUMPY_BUILD_DEP: numpy==1.13.3
64+
NUMPY_BUILD_DEP: numpy==1.14.5
6565

6666
- PYTHON: C:\Python36-x64
6767
PYTHON_VERSION: 3.6
6868
PYTHON_ARCH: 64
69-
NUMPY_BUILD_DEP: numpy==1.13.3
69+
NUMPY_BUILD_DEP: numpy==1.14.5
7070

7171
init:
7272
- "ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH%"
@@ -154,7 +154,7 @@ install:
154154
# Replace numpy distutils with a version that can build with msvc + mingw-gfortran.
155155
- ps: |
156156
$PYTHON_VERSION = $env:PYTHON_VERSION
157-
If ($PYTHON_VERSION -ne 3.8) {
157+
If ([System.Version]"$PYTHON_VERSION" -lt [System.Version]"3.8") {
158158
$NumpyDir = $((python -c 'import os; import numpy; print(os.path.dirname(numpy.__file__))') | Out-String).Trim()
159159
rm -r -Force "$NumpyDir\distutils"
160160
mv numpy-distutils\numpy\distutils $NumpyDir
@@ -166,17 +166,14 @@ build_script:
166166
- cd scipy
167167
- git checkout %BUILD_COMMIT%
168168
# we use a distribution file to assist in loading
169-
# DLLs with recent Python versions (>= 3.8)
169+
# DLLs
170170
- ps: |
171-
$PYTHON_VERSION = $env:PYTHON_VERSION
172-
If ($PYTHON_VERSION -eq 3.8) {
173-
cd ..
174-
$cwd = Get-Location
175-
ls $cwd
176-
rm -Force $cwd/scipy/scipy/_distributor_init.py
177-
mv $cwd/_distributor_init.py $cwd/scipy/scipy/
178-
cd scipy
179-
}
171+
cd ..
172+
$cwd = Get-Location
173+
ls $cwd
174+
rm -Force $cwd/scipy/scipy/_distributor_init.py
175+
mv $cwd/_distributor_init.py $cwd/scipy/scipy/
176+
cd scipy
180177
# Append license text relevant for the built wheel
181178
- type ..\LICENSE_win32.txt >> LICENSE.txt
182179
# Copy over additional DLLs to bundle to the wheels.
@@ -209,14 +206,7 @@ build_script:
209206
210207
before_test:
211208
# Install test requirements.
212-
- python -m pip install pytest pytest-xdist pytest-faulthandler pytest-env Pillow mpmath
213-
- ps: |
214-
$PYTHON_VERSION = $env:PYTHON_VERSION
215-
If ($PYTHON_VERSION -eq 3.8) {
216-
python -m pip install matplotlib==3.2.0rc1
217-
} Else {
218-
python -m pip install matplotlib
219-
}
209+
- python -m pip install pytest pytest-xdist pytest-faulthandler pytest-env Pillow mpmath matplotlib
220210

221211
# Upgrade numpy to the version used for testing
222212
- python -m pip install "%NUMPY_TEST_DEP%"

0 commit comments

Comments
 (0)