forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-wheel-macos.sh
executable file
·81 lines (69 loc) · 2.65 KB
/
build-wheel-macos.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
#!/bin/bash
# Cause the script to exit if a single command fails.
set -e
# Show explicitly which commands are currently running.
set -x
# Much of this is taken from https://github.com/matthew-brett/multibuild.
# This script uses "sudo", so you may need to type in a password a couple times.
MACPYTHON_URL=https://www.python.org/ftp/python
MACPYTHON_PY_PREFIX=/Library/Frameworks/Python.framework/Versions
DOWNLOAD_DIR=python_downloads
PY_VERSIONS=("2.7.13"
"3.4.4"
"3.5.3"
"3.6.1"
"3.7.0")
PY_INSTS=("python-2.7.13-macosx10.6.pkg"
"python-3.4.4-macosx10.6.pkg"
"python-3.5.3-macosx10.6.pkg"
"python-3.6.1-macosx10.6.pkg"
"python-3.7.0-macosx10.6.pkg")
PY_MMS=("2.7"
"3.4"
"3.5"
"3.6"
"3.7")
# On python 3.7, a newer version of numpy seems to be necessary.
NUMPY_VERSIONS=("1.10.4"
"1.10.4"
"1.10.4"
"1.10.4"
"1.14.5")
mkdir -p $DOWNLOAD_DIR
mkdir -p .whl
for ((i=0; i<${#PY_VERSIONS[@]}; ++i)); do
PY_VERSION=${PY_VERSIONS[i]}
PY_INST=${PY_INSTS[i]}
PY_MM=${PY_MMS[i]}
NUMPY_VERSION=${NUMPY_VERSIONS[i]}
# The -f flag is passed twice to also run git clean in the arrow subdirectory.
# The -d flag removes directories. The -x flag ignores the .gitignore file,
# and the -e flag ensures that we don't remove the .whl directory.
git clean -f -f -x -d -e .whl -e $DOWNLOAD_DIR
# Install Python.
INST_PATH=python_downloads/$PY_INST
curl $MACPYTHON_URL/$PY_VERSION/$PY_INST > $INST_PATH
sudo installer -pkg $INST_PATH -target /
PYTHON_EXE=$MACPYTHON_PY_PREFIX/$PY_MM/bin/python$PY_MM
PIP_CMD="$(dirname $PYTHON_EXE)/pip$PY_MM"
pushd /tmp
# Install latest version of pip to avoid brownouts
curl https://bootstrap.pypa.io/get-pip.py | $PYTHON_EXE
popd
pushd python
# Setuptools on CentOS is too old to install arrow 0.9.0, therefore we upgrade.
$PIP_CMD install --upgrade setuptools
# Install setuptools_scm because otherwise when building the wheel for
# Python 3.6, we see an error.
$PIP_CMD install -q setuptools_scm==3.1.0
# Fix the numpy version because this will be the oldest numpy version we can
# support.
$PIP_CMD install -q numpy==$NUMPY_VERSION cython==0.29.0
# Install wheel to avoid the error "invalid command 'bdist_wheel'".
$PIP_CMD install -q wheel
# Add the correct Python to the path and build the wheel. This is only
# needed so that the installation finds the cython executable.
INCLUDE_UI=1 PATH=$MACPYTHON_PY_PREFIX/$PY_MM/bin:$PATH $PYTHON_EXE setup.py bdist_wheel
mv dist/*.whl ../.whl/
popd
done