Skip to content

Commit ec4bbf1

Browse files
committed
statically link on posix, add aarch4 wheel build
1 parent c62d943 commit ec4bbf1

File tree

5 files changed

+36
-47
lines changed

5 files changed

+36
-47
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ install:
8686
script:
8787
# Build library and collect into libs subdirectory
8888
- build_lib "$PLAT" "$INTERFACE64"
89+
- source travis-ci/build_wheel.sh
8990

9091
after_success:
9192
# Upload libraries to the shared staging area on anaconda.org

local/scipy_openblas64/__init__.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
3+
"""
4+
15
import ctypes
26
import os
37
from pathlib import Path
@@ -26,26 +30,35 @@
2630

2731

2832
def get_include_dir():
33+
"""Return the include directory needed for compilation
34+
"""
2935
return os.path.join(_HERE, "include")
3036

3137

3238
def get_lib_dir():
39+
"""Return the lib directory needed for linking
40+
"""
3341
return os.path.join(_HERE, "lib")
3442

3543

3644
def get_library():
45+
"""Return the lib name needed for linking
46+
"""
3747
if sys.platform == "win32":
3848
libs = [x for x in os.listdir(get_lib_dir()) if x.endswith(".lib")]
3949
return os.path.splitext(libs[0])[0]
4050
else:
4151
return "openblas_python"
4252

4353
def get_pkg_config():
54+
"""Return a multi-line string that, when saved to a file, can be used with
55+
pkg-config for build systems like meson
56+
"""
4457
if sys.platform == "win32":
4558
extralib = "-defaultlib:advapi32 -lgfortran -defaultlib:advapi32 -lgfortran"
4659
else:
4760
extralib = "-lm -lpthread -lgfortran -lm -lpthread -lgfortran"
48-
return f"""\
61+
return dedent(f"""\
4962
libdir={get_lib_dir()}
5063
includedir={get_include_dir()}
5164
openblas_config= {openblas_config}
@@ -58,15 +71,27 @@ def get_pkg_config():
5871
Libs: -L${libdir} -l{get_library()}
5972
Libs.private: ${extralib}
6073
Cflags: -I${includedir}
61-
"""
74+
""")
6275

6376

6477
if sys.platform == "win32":
6578
os.add_dll_directory(get_lib_dir())
6679

67-
80+
def write__distributor_init(target):
81+
"""Accepts a Pathlib or string of a directory.
82+
Write a pre-import file that will import scipy_openblas64 before
83+
continuing to import the library. This will load OpenBLAS into the
84+
executable's namespace and make the functions available for use.
85+
"""
86+
fname = os.path.join(target, "_distributor_init.py")
87+
with open(fname, "wt", encoding="utf8") as fid:
88+
fid.write(dedent(f"""\
89+
""")
6890

6991
def _get_openblas_config():
92+
"""Use ctypes to pull out the config string from the OpenBLAS library.
93+
It will be available as `openblas_config`
94+
"""
7095
lib_dir = get_lib_dir()
7196
if sys.platform == "win32":
7297
# Get libopenblas*.lib
@@ -78,6 +103,6 @@ def _get_openblas_config():
78103
dll = ctypes.CDLL(os.path.join(lib_dir, libnames[0]))
79104
openblas_config = dll.openblas_get_config64_
80105
openblas_config.restype = ctypes.c_char_p
81-
return openblas_config
106+
return openblas_config()
82107

83108
openblas_config = _get_openblas_config()

src/_init_openblas.c

Lines changed: 0 additions & 41 deletions
This file was deleted.

travis-ci/build_steps.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ function do_build_lib {
165165
git config --global --add safe.directory '*'
166166
pushd OpenBLAS
167167
patch_source
168-
CFLAGS="$CFLAGS -fvisibility=protected" make BUFFERSIZE=20 DYNAMIC_ARCH=1 USE_OPENMP=0 NUM_THREADS=64 BINARY=$bitness $interface64_flags $target_flags > /dev/null
168+
CFLAGS="$CFLAGS -fvisibility=protected" \
169+
make BUFFERSIZE=20 DYNAMIC_ARCH=1 \
170+
USE_OPENMP=0 NUM_THREADS=64 \
171+
LDFLAGS="-static ${LDFLAGS}"
172+
BINARY=$bitness $interface64_flags $target_flags > /dev/null
169173
make PREFIX=$BUILD_PREFIX $interface64_flags install
170174
popd
171175
stop_spinner

travis-ci/build_wheel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ if [ $(uname) == "Darwin" ]; then
5454
for f in dist/*.whl; do mv $f "${f/%any.whl/macosx_10_9_$PLAT.whl}"; done
5555
delocate-wheel -v dist/*.whl
5656
else
57-
auditwheel repair -w dist dist/*.whl
57+
auditwheel repair -w dist --lib-sdir /lib dist/*.whl
5858
rm dist/scipy_openblas*-none-any.whl
5959
fi
6060

0 commit comments

Comments
 (0)