Skip to content

Commit e6c99f5

Browse files
committed
fix travis error
Co-authored by: nijincheng@iscas.ac.cn;
1 parent cce6ab5 commit e6c99f5

File tree

3 files changed

+97
-66
lines changed

3 files changed

+97
-66
lines changed

ci-before-build.sh

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -125,69 +125,4 @@ function cmd_notexit {
125125
# Build OpenBLAS
126126
source build-openblas.sh
127127

128-
129-
ls libs/openblas* >/dev/null 2>&1 && true
130-
if [ "$?" != "0" ]; then
131-
# inside docker
132-
cd /project
133-
fi
134-
PYTHON=${PYTHON:-python3.9}
135-
136-
mkdir -p local/openblas
137-
mkdir -p dist
138-
$PYTHON -m pip install wheel auditwheel
139-
140-
# This will fail if there is more than one file in libs
141-
tar -C local/scipy_openblas64 --strip-components=2 -xf libs/openblas*.tar.gz
142-
143-
# do not package the static libs and symlinks, only take the shared object
144-
find local/scipy_openblas64/lib -maxdepth 1 -type l -delete
145-
rm local/scipy_openblas64/lib/*.a
146-
# Check that the pyproject.toml and the pkgconfig versions agree.
147-
py_version=$(grep "^version" pyproject.toml | sed -e "s/version = \"//")
148-
pkg_version=$(grep "version=" ./local/scipy_openblas64/lib/pkgconfig/scipy-openblas*.pc | sed -e "s/version=//" | sed -e "s/dev//")
149-
if [[ -z "$pkg_version" ]]; then
150-
echo Could not read version from pkgconfig file
151-
exit 1
152-
fi
153-
if [[ $py_version != $pkg_version* ]]; then
154-
echo Version from pyproject.toml "$py_version" does not match version from build "pkg_version"
155-
exit 1
156-
fi
157-
158-
if [ $(uname) == "Darwin" ]; then
159-
soname=$(cd local/scipy_openblas64/lib; ls libscipy_openblas*.dylib)
160-
echo otool -D local/scipy_openblas64/lib/$soname
161-
otool -D local/scipy_openblas64/lib/$soname
162-
# issue 153: there is a ".0" in the install_name. Remove it
163-
# also add a @rpath
164-
install_name_tool -id @rpath/$soname local/scipy_openblas64/lib/$soname
165-
fi
166-
167-
rm -rf local/scipy_openblas64/lib/pkgconfig
168-
echo "" >> LICENSE.txt
169-
echo "----" >> LICENSE.txt
170-
echo "" >> LICENSE.txt
171-
if [ $(uname) == "Darwin" ]; then
172-
cat tools/LICENSE_osx.txt >> LICENSE.txt
173-
else
174-
cat tools/LICENSE_linux.txt >> LICENSE.txt
175-
fi
176-
177-
if [ "${INTERFACE64}" != "1" ]; then
178-
# rewrite the name of the project to scipy-openblas32
179-
# this is a hack, but apparently there is no other way to change the name
180-
# of a pyproject.toml project
181-
#
182-
# use the BSD variant of sed -i and remove the backup
183-
sed -e "s/openblas64/openblas32/" -i.bak pyproject.toml
184-
rm *.bak
185-
mv local/scipy_openblas64 local/scipy_openblas32
186-
sed -e "s/openblas_get_config64_/openblas_get_config/" -i.bak local/scipy_openblas32/__init__.py
187-
sed -e "s/cflags =.*/cflags = '-DBLAS_SYMBOL_PREFIX=scipy_'/" -i.bak local/scipy_openblas32/__init__.py
188-
sed -e "s/openblas64/openblas32/" -i.bak local/scipy_openblas32/__main__.py
189-
sed -e "s/openblas64/openblas32/" -i.bak local/scipy_openblas32/__init__.py
190-
rm local/scipy_openblas32/*.bak
191-
fi
192-
193-
rm -rf dist/*
128+
source tools/build_prepare.sh

tools/build_prepare.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#! /bin/bash
2+
3+
set -xe
4+
5+
ls libs/openblas* >/dev/null 2>&1 && true
6+
if [ "$?" != "0" ]; then
7+
# inside docker
8+
cd /project
9+
fi
10+
PYTHON=${PYTHON:-python3.9}
11+
12+
mkdir -p local/openblas
13+
mkdir -p dist
14+
$PYTHON -m pip install wheel auditwheel
15+
16+
# This will fail if there is more than one file in libs
17+
tar -C local/scipy_openblas64 --strip-components=2 -xf libs/openblas*.tar.gz
18+
19+
# do not package the static libs and symlinks, only take the shared object
20+
find local/scipy_openblas64/lib -maxdepth 1 -type l -delete
21+
rm local/scipy_openblas64/lib/*.a
22+
# Check that the pyproject.toml and the pkgconfig versions agree.
23+
py_version=$(grep "^version" pyproject.toml | sed -e "s/version = \"//")
24+
pkg_version=$(grep "version=" ./local/scipy_openblas64/lib/pkgconfig/scipy-openblas*.pc | sed -e "s/version=//" | sed -e "s/dev//")
25+
if [[ -z "$pkg_version" ]]; then
26+
echo Could not read version from pkgconfig file
27+
exit 1
28+
fi
29+
if [[ $py_version != $pkg_version* ]]; then
30+
echo Version from pyproject.toml "$py_version" does not match version from build "pkg_version"
31+
exit 1
32+
fi
33+
34+
if [ $(uname) == "Darwin" ]; then
35+
soname=$(cd local/scipy_openblas64/lib; ls libscipy_openblas*.dylib)
36+
echo otool -D local/scipy_openblas64/lib/$soname
37+
otool -D local/scipy_openblas64/lib/$soname
38+
# issue 153: there is a ".0" in the install_name. Remove it
39+
# also add a @rpath
40+
install_name_tool -id @rpath/$soname local/scipy_openblas64/lib/$soname
41+
fi
42+
43+
rm -rf local/scipy_openblas64/lib/pkgconfig
44+
echo "" >> LICENSE.txt
45+
echo "----" >> LICENSE.txt
46+
echo "" >> LICENSE.txt
47+
if [ $(uname) == "Darwin" ]; then
48+
cat tools/LICENSE_osx.txt >> LICENSE.txt
49+
else
50+
cat tools/LICENSE_linux.txt >> LICENSE.txt
51+
fi
52+
53+
if [ "${INTERFACE64}" != "1" ]; then
54+
# rewrite the name of the project to scipy-openblas32
55+
# this is a hack, but apparently there is no other way to change the name
56+
# of a pyproject.toml project
57+
#
58+
# use the BSD variant of sed -i and remove the backup
59+
sed -e "s/openblas64/openblas32/" -i.bak pyproject.toml
60+
rm *.bak
61+
mv local/scipy_openblas64 local/scipy_openblas32
62+
sed -e "s/openblas_get_config64_/openblas_get_config/" -i.bak local/scipy_openblas32/__init__.py
63+
sed -e "s/cflags =.*/cflags = '-DBLAS_SYMBOL_PREFIX=scipy_'/" -i.bak local/scipy_openblas32/__init__.py
64+
sed -e "s/openblas64/openblas32/" -i.bak local/scipy_openblas32/__main__.py
65+
sed -e "s/openblas64/openblas32/" -i.bak local/scipy_openblas32/__init__.py
66+
rm local/scipy_openblas32/*.bak
67+
fi
68+
69+
rm -rf dist/*

tools/build_wheel.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,32 @@
22
# $INTERFACE64 ("1" or "0")
33
# $PLAT (x86_64, i686, arm64, aarch64, s390x, ppc64le)
44

5+
source tools/build_prepare.sh
6+
57
$PYTHON -m pip wheel -w dist -v .
68

9+
# The code below is for Travis use only.
10+
11+
auditwheel repair -w dist --lib-sdir /lib dist/*.whl
12+
rm dist/scipy_openblas*-none-any.whl
13+
# Add an RPATH to libgfortran:
14+
# https://github.com/pypa/auditwheel/issues/451
15+
if [ "$MB_ML_LIBC" == "musllinux" ]; then
16+
apk add zip
17+
else
18+
yum install -y zip
19+
fi
20+
unzip dist/*.whl "*libgfortran*"
21+
patchelf --force-rpath --set-rpath '$ORIGIN' */lib/libgfortran*
22+
zip dist/*.whl */lib/libgfortran*
23+
24+
# Test that the wheel works with a different python
25+
PYTHON=python3.11
26+
27+
if [ "${INTERFACE64}" != "1" ]; then
28+
$PYTHON -m pip install --no-index --find-links dist scipy_openblas32
29+
$PYTHON -m scipy_openblas32
30+
else
31+
$PYTHON -m pip install --no-index --find-links dist scipy_openblas64
32+
$PYTHON -m scipy_openblas64
33+
fi

0 commit comments

Comments
 (0)