-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild_wheels_linux.sh
More file actions
executable file
·117 lines (98 loc) · 3.17 KB
/
build_wheels_linux.sh
File metadata and controls
executable file
·117 lines (98 loc) · 3.17 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/sh
set -e -x
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
NPROC=$(cat /proc/cpuinfo | awk '/^processor/{print $3}' | wc -l)
NUM_WORKERS=$((NPROC))
MAKEOPTS="-j$NUM_WORKERS"
# Place to store wheels.
WHEELHOUSE=${1-$HOME/wheelhouse}
echo "Path to store wheels : $WHEELHOUSE"
mkdir -p $WHEELHOUSE
# tag on github and revision number. Make sure that they are there.
BRANCH=$(cat ./BRANCH)
VERSION="4.0.dev$(date +%Y%m%d)"
# Create a test script and upload.
TESTFILE=/tmp/test.py
cat <<EOF >$TESTFILE
import moose
import moose.utils as mu
print( moose.version() )
moose.reinit()
moose.start( 1 )
EOF
echo "Building version $VERSION, from branch $BRANCH"
if [ ! -f /usr/local/lib/libgsl.a ]; then
#wget --no-check-certificate ftp://ftp.gnu.org/gnu/gsl/gsl-2.4.tar.gz
curl -O https://ftp.gnu.org/gnu/gsl/gsl-2.4.tar.gz
tar xvf gsl-2.4.tar.gz
cd gsl-2.4
CFLAGS=-fPIC ./configure --enable-static && make $MAKEOPTS
make install
cd ..
fi
MOOSE_SOURCE_DIR=$SCRIPT_DIR/moose-core
if [ -d $MOOSE_SOURCE_DIR ]; then
cd $MOOSE_SOURCE_DIR && git checkout $BRANCH && git pull origin $BRANCH
rm -rf dist
else
git clone https://github.com/bhallalab/moose-core $MOOSE_SOURCE_DIR \
--depth 1 --branch $BRANCH
fi
# Try to link statically.
GSL_STATIC_LIBS="/usr/local/lib/libgsl.a;/usr/local/lib/libgslcblas.a"
CMAKE=/usr/bin/cmake3
# Build wheels here.
#PY27=$(ls /opt/python/cp27-cp27m/bin/python?.?)
PY35=$(ls /opt/python/cp35-cp35m/bin/python?.?)
#PY36=$(ls /opt/python/cp36-cp36m/bin/python?.?)
PY37=$(ls /opt/python/cp37-cp37m/bin/python?.?)
PY38=$(ls /opt/python/cp38-cp38/bin/python?.?)
for PYTHON in $PY38 $PY37 $PY36 $PY35 $PY27; do
echo "========= Building using $PYTHON ..."
$PYTHON -m pip install pip setuptools --upgrade
if [[ "$PYV" -eq "27" ]]; then
$PYTHON -m pip install numpy==1.15
$PYTHON -m pip install matplotlib==2.2.3
else
$PYTHON -m pip install numpy twine
$PYTHON -m pip install matplotlib
fi
$PYTHON -m pip install twine
# Removing existing pymoose if any.
$PYTHON -m pip uninstall pymoose -y || echo "No pymoose"
cd $MOOSE_SOURCE_DIR
export GSL_USE_STATIC_LIBRARIES=1
$PYTHON setup.py build_ext
$PYTHON setup.py bdist_wheel --skip-build
(
echo "Install and test this wheel"
# NOTE: Not sure why I have to do this. But cant install wheel from build
# directory.
cd /tmp
$PYTHON -m pip install $MOOSE_SOURCE_DIR/dist/*.whl
$PYTHON $TESTFILE
mv $MOOSE_SOURCE_DIR/dist/*.whl $WHEELHOUSE
rm -rf $MOOSE_SOURCE_DIR/dist/*.whl
)
done
# List all wheels.
ls -lh $WHEELHOUSE/*.whl
# now check the wheels.
for whl in $WHEELHOUSE/pymoose*.whl; do
auditwheel show "$whl"
# Fix the tag and remove the old wheel.
auditwheel repair "$whl" -w $WHEELHOUSE && rm -f "$whl"
done
# upload to PYPI.
$PY38 -m pip install twine
TWINE="$PY38 -m twine"
for whl in `find $WHEELHOUSE -name "pymoose*.whl"`; do
# If successful, upload using twine.
if [ -n "$PYMOOSE_PYPI_PASSWORD" ]; then
$TWINE upload $whl \
--user bhallalab \
--password $PYMOOSE_PYPI_PASSWORD --skip-existing
else
echo "PYPI password is not set"
fi
done