build-wheel-macos-arm64.sh 2.8 KB

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