mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00

* Add script for building MacOS wheels. * Small cleanups to script. * Fix setting of PATH before building wheel. * Create symbolic link to correct Python executable so Ray installation finds the right Python. * Address comments. * Rename readme.
65 lines
2.1 KiB
Bash
Executable file
65 lines
2.1 KiB
Bash
Executable file
#!/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")
|
|
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")
|
|
PY_MMS=("2.7"
|
|
"3.4"
|
|
"3.5"
|
|
"3.6")
|
|
|
|
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]}
|
|
|
|
# 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 /
|
|
|
|
# Create a link from "python" to the actual Python executable so that the
|
|
# Python on the path that Ray finds is the correct version.
|
|
if [ ! -e $MACPYTHON_PY_PREFIX/$PY_MM/bin/python ]; then
|
|
ln -s $MACPYTHON_PY_PREFIX/$PY_MM/bin/python$PY_MM $MACPYTHON_PY_PREFIX/$PY_MM/bin/python
|
|
fi
|
|
PYTHON_EXE=$MACPYTHON_PY_PREFIX/$PY_MM/bin/python
|
|
PIP_CMD="$(dirname $PYTHON_EXE)/pip$PY_MM"
|
|
|
|
pushd python
|
|
# Fix the numpy version because this will be the oldest numpy version we can
|
|
# support.
|
|
$PIP_CMD install numpy==1.10.4
|
|
# Install wheel to avoid the error "invalid command 'bdist_wheel'".
|
|
$PIP_CMD install wheel
|
|
# Add the correct Python to the path and build the wheel.
|
|
PATH=$MACPYTHON_PY_PREFIX/$PY_MM/bin:$PATH $PYTHON_EXE setup.py bdist_wheel
|
|
mv dist/*.whl ../.whl/
|
|
popd
|
|
done
|