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

Commit d10f8a0

Browse files
committed
Refactor to use gfortran install
1 parent 90ef810 commit d10f8a0

File tree

5 files changed

+71
-21
lines changed

5 files changed

+71
-21
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
[submodule "multibuild"]
88
path = multibuild
99
url = https://github.com/matthew-brett/multibuild.git
10+
[submodule "gfortran-install"]
11+
path = gfortran-install
12+
url = https://github.com/MacPython/gfortran-install.git

archives/gfortran-4.2.3.pkg

-26.7 MB
Binary file not shown.

config.sh

+66-20
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,80 @@
11
# Define custom utilities
22
# Test for OSX with [ -n "$IS_OSX" ]
3+
OPENBLAS_VERSION=0.2.18
4+
source gfortran-install/gfortran_utils.sh
35

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 $@
1012
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
2165
}
2266

2367
function run_tests {
2468
# Runs tests on installed distribution from an empty directory
2569
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())"
2873
arch -i386 python -c "$test_cmd"
2974
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())"
3278
python -c "$test_cmd"
3379
fi
3480
# Show BLAS / LAPACK used

gfortran-install

Submodule gfortran-install added at d349963

0 commit comments

Comments
 (0)