build-wheel-macos-arm64.sh 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/bin/bash
  2. # Cause the script to exit if a single command fails.
  3. set -e
  4. # Show explicitly which commands are currently running.
  5. set -x
  6. DOWNLOAD_DIR=python_downloads
  7. NODE_VERSION="14"
  8. PY_VERSIONS=("3.8.2"
  9. "3.9.1"
  10. "3.10.4")
  11. PY_MMS=("3.8"
  12. "3.9"
  13. "3.10")
  14. if [[ -n "${SKIP_DEP_RES}" ]]; then
  15. ./ci/env/install-bazel.sh
  16. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
  17. curl -o- https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh | bash
  18. conda init bash
  19. source ~/.bash_profile
  20. # Use the latest version of Node.js in order to build the dashboard.
  21. source "$HOME"/.nvm/nvm.sh
  22. nvm install $NODE_VERSION
  23. nvm use $NODE_VERSION
  24. fi
  25. # Build the dashboard so its static assets can be included in the wheel.
  26. pushd python/ray/dashboard/client
  27. source "$HOME"/.nvm/nvm.sh
  28. npm ci
  29. npm run build
  30. popd
  31. mkdir -p .whl
  32. for ((i=0; i<${#PY_VERSIONS[@]}; ++i)); do
  33. PY_MM=${PY_MMS[i]}
  34. CONDA_ENV_NAME="p$PY_MM"
  35. # The -f flag is passed twice to also run git clean in the arrow subdirectory.
  36. # The -d flag removes directories. The -x flag ignores the .gitignore file,
  37. # and the -e flag ensures that we don't remove the .whl directory.
  38. git clean -f -f -x -d -e .whl -e $DOWNLOAD_DIR -e python/ray/dashboard/client -e dashboard/client
  39. # Install python using conda. This should be easier to produce consistent results in buildkite and locally.
  40. [ ! -f "$HOME/.bash_profile" ] && conda init bash
  41. source ~/.bash_profile
  42. conda create -y -n "$CONDA_ENV_NAME"
  43. conda activate "$CONDA_ENV_NAME"
  44. conda remove -y python || true
  45. conda install -y python="$PY_MM"
  46. # NOTE: We expect conda to set the PATH properly.
  47. PIP_CMD=pip
  48. PYTHON_EXE=python
  49. $PIP_CMD install --upgrade pip
  50. if [ -z "${TRAVIS_COMMIT}" ]; then
  51. TRAVIS_COMMIT=${BUILDKITE_COMMIT}
  52. fi
  53. pushd python
  54. # Setuptools on CentOS is too old to install arrow 0.9.0, therefore we upgrade.
  55. # TODO: Unpin after https://github.com/pypa/setuptools/issues/2849 is fixed.
  56. $PIP_CMD install --upgrade setuptools==58.4
  57. $PIP_CMD install -q cython==0.29.32
  58. # Install wheel to avoid the error "invalid command 'bdist_wheel'".
  59. $PIP_CMD install -q wheel
  60. # Set the commit SHA in __init__.py.
  61. if [ -n "$TRAVIS_COMMIT" ]; then
  62. echo "TRAVIS_COMMIT variable detected. ray.__commit__ will be set to $TRAVIS_COMMIT"
  63. else
  64. echo "TRAVIS_COMMIT variable is not set, getting the current commit from git."
  65. TRAVIS_COMMIT=$(git rev-parse HEAD)
  66. fi
  67. sed -i .bak "s/{{RAY_COMMIT_SHA}}/$TRAVIS_COMMIT/g" ray/__init__.py && rm ray/__init__.py.bak
  68. # Add the correct Python to the path and build the wheel. This is only
  69. # needed so that the installation finds the cython executable.
  70. # build ray wheel
  71. $PYTHON_EXE setup.py bdist_wheel
  72. # build ray-cpp wheel
  73. RAY_INSTALL_CPP=1 $PYTHON_EXE setup.py bdist_wheel
  74. mv dist/*.whl ../.whl/
  75. popd
  76. done