|
1 | 1 | # Define custom utilities
|
2 | 2 | # Test for OSX with [ -n "$IS_OSX" ]
|
| 3 | +OPENBLAS_VERSION=0.2.18 |
| 4 | +source gfortran-install/gfortran_utils.sh |
3 | 5 |
|
4 |
| -function pre_build { |
5 |
| - # Any stuff that you need to do before you start building the wheels |
6 |
| - # Runs in the root directory of this repository. |
7 |
| - if [ -n "$IS_OSX" ]; then |
8 |
| - sudo installer -pkg archives/gfortran-4.2.3.pkg -target / |
9 |
| - return |
| 6 | +function build_wheel { |
| 7 | + if [ -z "$IS_OSX" ]; then |
| 8 | + build_libs $PLAT |
| 9 | + build_pip_wheel $@ |
| 10 | + else |
| 11 | + build_osx_wheel $@ |
10 | 12 | fi
|
11 |
| - # Rackspace builds of openblas |
12 |
| - local lib_url=https://d9a97980b71d47cde94d-aae005c4999d7244ac63632f8b80e089.ssl.cf2.rackcdn.com |
13 |
| - local lib_tgz="openblas_0.2.18-$(get_platform).tgz" |
14 |
| - (cd / && curl -LO $lib_url/${lib_tgz} && tar zxf $lib_tgz) |
15 |
| - # Force scipy to use OpenBLAS regardless of what numpy uses |
16 |
| - cat << EOF > $HOME/site.cfg |
17 |
| -[openblas] |
18 |
| -library_dirs = /usr/local/lib |
19 |
| -include_dirs = /usr/local/include |
20 |
| -EOF |
| 13 | +} |
| 14 | + |
| 15 | +function build_libs { |
| 16 | + if [ -n "$IS_OSX" ]; then return; fi # No OpenBLAS for OSX |
| 17 | + local plat=${1:-$PLAT} |
| 18 | + local tar_path=$(abspath $(get_gf_lib "openblas-${OPENBLAS_VERSION}" "$plat")) |
| 19 | + (cd / && tar zxf $tar_path) |
| 20 | +} |
| 21 | + |
| 22 | +function set_arch { |
| 23 | + local arch=$1 |
| 24 | + export CC="clang $arch" |
| 25 | + export CXX="clang++ $arch" |
| 26 | + export CFLAGS="$arch" |
| 27 | + export FFLAGS="$arch" |
| 28 | + export FARCH="$arch" |
| 29 | + export LDFLAGS="$arch" |
| 30 | +} |
| 31 | + |
| 32 | +function build_osx_wheel { |
| 33 | + # Build dual arch wheel |
| 34 | + # Standard gfortran won't build dual arch objects, so we have to build two |
| 35 | + # wheels, one for 32-bit, one for 64, then fuse them. |
| 36 | + local repo_dir=${1:-$REPO_DIR} |
| 37 | + local wheelhouse=$(abspath ${WHEEL_SDIR:-wheelhouse}) |
| 38 | + local py_ld_flags="-Wall -undefined dynamic_lookup -bundle" |
| 39 | + local wheelhouse32=${wheelhouse}32 |
| 40 | + |
| 41 | + install_gfortran |
| 42 | + # 32-bit wheel |
| 43 | + local arch="-m32" |
| 44 | + set_arch $arch |
| 45 | + # Build libraries |
| 46 | + build_libs i686 |
| 47 | + # Build wheel |
| 48 | + mkdir -p $wheelhouse32 |
| 49 | + export LDSHARED="$CC $py_ld_flags" |
| 50 | + export LDFLAGS="$arch $py_ld_flags" |
| 51 | + build_pip_wheel "$repo_dir" |
| 52 | + mv ${wheelhouse}/*whl $wheelhouse32 |
| 53 | + # 64-bit wheel |
| 54 | + local arch="-m64" |
| 55 | + set_arch $arch |
| 56 | + build_libs x86_64 |
| 57 | + # Build wheel |
| 58 | + export LDSHARED="$CC $py_ld_flags" |
| 59 | + export LDFLAGS="$arch $py_ld_flags" |
| 60 | + build_pip_wheel "$repo_dir" |
| 61 | + # Fuse into dual arch wheel(s) |
| 62 | + for whl in ${wheelhouse}/*.whl; do |
| 63 | + delocate-fuse "$whl" "${wheelhouse32}/$(basename $whl)" |
| 64 | + done |
21 | 65 | }
|
22 | 66 |
|
23 | 67 | function run_tests {
|
24 | 68 | # Runs tests on installed distribution from an empty directory
|
25 | 69 | if [ -n "$IS_OSX" ]; then # Test both architectures on OSX
|
26 |
| - # Can't afford full tests when running both test rigs in same job |
27 |
| - test_cmd="import sys; import scipy; sys.exit(not scipy.test().wasSuccessful())" |
| 70 | + # Can't afford full tests because of two-arch build / test |
| 71 | + test_cmd="import sys; import scipy; \ |
| 72 | + sys.exit(not scipy.test().wasSuccessful())" |
28 | 73 | arch -i386 python -c "$test_cmd"
|
29 | 74 | arch -x86_64 python -c "$test_cmd"
|
30 |
| - else # Not OSX |
31 |
| - test_cmd="import sys; import scipy; sys.exit(not scipy.test('full').wasSuccessful())" |
| 75 | + else |
| 76 | + test_cmd="import sys; import scipy; \ |
| 77 | + sys.exit(not scipy.test('full').wasSuccessful())" |
32 | 78 | python -c "$test_cmd"
|
33 | 79 | fi
|
34 | 80 | # Show BLAS / LAPACK used
|
|
0 commit comments