-
Notifications
You must be signed in to change notification settings - Fork 6
/
build-wheels.sh
executable file
·71 lines (59 loc) · 2.09 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
#!/bin/bash
set -e -x
function install_rust {
curl https://sh.rustup.rs > /tmp/rustup.sh
curl https://static.rust-lang.org/rustup.sh > /tmp/rustup.sh
chmod +x /tmp/rustup.sh
/tmp/rustup.sh -y --disable-sudo --channel=$1
}
function clean_project {
# Remove compiled files that might cause conflicts
pushd /io/
rm -rf .cache .eggs rust_fst/_ffi.py build *.egg-info
find ./ -name "__pycache__" -type d -print0 |xargs -0 rm -rf
find ./ -name "*.pyc" -type f -print0 |xargs -0 rm -rf
find ./ -name "*.so" -type f -print0 |xargs -0 rm -rf
popd
}
RUST_CHANNEL=nightly
# It doesn't matter with which Python version we build the wheel, so we
# use the oldest supported one
if [[ $1 == "osx" ]]; then
brew update
brew install
pip install -U pip setuptools wheel
install_rust $RUST_CHANNEL
pip wheel . -w ./wheelhouse
pip install -v rust_fst --no-index -f ./wheelhouse
pip install -r "test-requirements.txt"
cd ../
py.test ./python-rust-fst/tests
else
PYBIN=/opt/python/cp27-cp27m/bin
# Clean build files
clean_project
install_rust $RUST_CHANNEL
# Remove old wheels
rm -rf /io/wheelhouse/* || echo "No old wheels to delete"
# Install libraries needed for compiling the extension
yum -q -y install libffi-devel
# Compile wheel
${PYBIN}/python -m pip wheel /io/ -w /wheelhouse/
# Move pure wheels to target directory
mkdir -p /io/wheelhouse
mv /wheelhouse/*any.whl /io/wheelhouse || echo "No pure wheels to move"
# Bundle external shared libraries into the wheel
for whl in /wheelhouse/*.whl; do
auditwheel repair $whl -w /io/wheelhouse/
done
# Set permissions on wheels
chmod -R a+rw /io/wheelhouse
# Install packages and test with all Python versions
for PYBIN in /opt/python/*/bin/; do
${PYBIN}/python -m pip install cffi
${PYBIN}/python -m pip install -r "/io/test-requirements.txt"
${PYBIN}/python -m pip install rust_fst --no-index -f /io/wheelhouse
${PYBIN}/python -m pytest --verbose /io/tests
clean_project
done
fi