mirror of
https://github.com/wassname/ray.git
synced 2026-06-29 04:44:28 +08:00
Add script for building MacOS wheels. (#601)
* 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.
This commit is contained in:
committed by
Philipp Moritz
parent
b94b4a35e0
commit
bcaab78908
@@ -6,10 +6,21 @@ repository, including both changes to tracked files, and ANY untracked files.
|
||||
It will also cause all files inside the repository to be owned by root, and
|
||||
produce .whl files owned by root.
|
||||
|
||||
Inside the root directory (i.e. one level above this python directory), run
|
||||
Inside the root directory (i.e., one level above this python directory), run
|
||||
|
||||
```
|
||||
docker run --rm -w /ray -v `pwd`:/ray -ti quay.io/xhochy/arrow_manylinux1_x86_64_base:ARROW-1024 /ray/python/build-wheel-manylinux1.sh
|
||||
```
|
||||
|
||||
The wheel files will be placed in the .whl directory.
|
||||
|
||||
## Building MacOS wheels
|
||||
|
||||
To build wheels for MacOS, run the following inside the root directory (i.e.,
|
||||
one level above this python directory).
|
||||
|
||||
```
|
||||
./python/build-wheel-macos.sh
|
||||
```
|
||||
|
||||
The script uses `sudo` multiple times, so you may need to type in a password.
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user