forked from facebookresearch/fastText
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build-wheels.sh
85 lines (75 loc) · 2.29 KB
/
build-wheels.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
#
# Called inside the manylinux image
#
# based on https://github.com/lxml/lxml/blob/b224e0f69dde58425d1077e07d193d19d3f803a9/tools/manylinux/build-wheels.sh
echo "Started $0 $@"
set -e -x
[ -n "$WHEELHOUSE" ] || WHEELHOUSE=wheelhouse
SDIST=$1
PACKAGE=$(basename ${SDIST%-*})
SDIST_PREFIX='fasttext_predict'
[ -z "$PYTHON_BUILD_VERSION" ] && PYTHON_BUILD_VERSION="*"
build_wheel() {
echo "===[ build_wheels $1 $2 ]==="
pybin="$1"
source="$2"
[ -n "$source" ] || source=/io
${pybin}/pip install --upgrade pip
case $( uname -m ) in
x86_64|i686|amd64) CFLAGS="$CFLAGS -march=core2";;
aarch64) CFLAGS="$CFLAGS -march=armv8-a -mtune=cortex-a72";;
esac
rm -rf /io/build
env STATIC_DEPS=true \
RUN_TESTS=true \
LDFLAGS="$LDFLAGS -fPIC" \
CFLAGS="$CFLAGS -fPIC" \
ACLOCAL_PATH=/usr/share/aclocal/ \
${pybin}/pip \
wheel \
-v \
"$source" \
-w /io/$WHEELHOUSE
}
prepare_system() {
echo "===[ prepare_system ]==="
rm -fr /opt/python/cp27-*
rm -fr /opt/python/cp34-*
rm -fr /opt/python/cp35-*
rm -fr /opt/python/cp36-*
echo "Python versions found: $(cd /opt/python && echo cp* | sed -e 's|[^ ]*-||g')"
${CC:-gcc} --version
}
build_wheels() {
echo "===[ build_wheels ]==="
# Compile wheels for all python versions
test -e "$SDIST" && source="$SDIST" || source=
for PYBIN in /opt/python/${PYTHON_BUILD_VERSION}/bin; do
echo "Starting build with $($PYBIN/python -V)"
build_wheel "$PYBIN" "$source"
done
}
repair_wheels() {
echo "===[ repair_wheels ]==="
# Bundle external shared libraries into the wheels
for whl in /io/$WHEELHOUSE/${SDIST_PREFIX}-*.whl; do
OPT="--strip"
if [[ "$whl" == *x86_64.whl && "$whl" == *manylinux_2_24_x86_64* ]]; then
OPT="$OPT --plat manylinux_2_34_x86_64"
fi
if [[ "$whl" == *x86_64.whl && "$whl" == *manylinux1_x86_64* ]]; then
OPT="$OPT --plat manylinux1_x86_64"
fi
auditwheel show $whl
auditwheel repair $whl $OPT -w /io/$WHEELHOUSE || exit 1
done
}
show_wheels() {
echo "===[ show_wheels ]==="
ls -l /io/$WHEELHOUSE/${SDIST_PREFIX}-*.whl
}
prepare_system
build_wheels
repair_wheels
show_wheels