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. source ~/.bash_profile
  19. conda init bash
  20. source ~/.bash_profile
  21. # Use the latest version of Node.js in order to build the dashboard.
  22. source "$HOME"/.nvm/nvm.sh
  23. nvm install $NODE_VERSION
  24. nvm use $NODE_VERSION
  25. fi
  26. # Build the dashboard so its static assets can be included in the wheel.
  27. pushd python/ray/dashboard/client
  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. source ~/.bash_profile
  41. conda create -y -n "$CONDA_ENV_NAME"
  42. conda activate "$CONDA_ENV_NAME"
  43. conda remove -y python || true
  44. conda install -y python="$PY_MM"
  45. # NOTE: We expect conda to set the PATH properly.
  46. PIP_CMD=pip
  47. PYTHON_EXE=python
  48. $PIP_CMD install --upgrade pip
  49. if [ -z "${TRAVIS_COMMIT}" ]; then
  50. TRAVIS_COMMIT=${BUILDKITE_COMMIT}
  51. fi
  52. pushd python
  53. # Setuptools on CentOS is too old to install arrow 0.9.0, therefore we upgrade.
  54. # TODO: Unpin after https://github.com/pypa/setuptools/issues/2849 is fixed.
  55. $PIP_CMD install --upgrade setuptools==58.4
  56. $PIP_CMD install -q cython==0.29.32
  57. # Install wheel to avoid the error "invalid command 'bdist_wheel'".
  58. $PIP_CMD install -q wheel
  59. # Set the commit SHA in __init__.py.
  60. if [ -n "$TRAVIS_COMMIT" ]; then
  61. echo "TRAVIS_COMMIT variable detected. ray.__commit__ will be set to $TRAVIS_COMMIT"
  62. else
  63. echo "TRAVIS_COMMIT variable is not set, getting the current commit from git."
  64. TRAVIS_COMMIT=$(git rev-parse HEAD)
  65. fi
  66. sed -i .bak "s/{{RAY_COMMIT_SHA}}/$TRAVIS_COMMIT/g" ray/__init__.py && rm ray/__init__.py.bak
  67. # Add the correct Python to the path and build the wheel. This is only
  68. # needed so that the installation finds the cython executable.
  69. # build ray wheel
  70. $PYTHON_EXE setup.py bdist_wheel
  71. # build ray-cpp wheel
  72. RAY_INSTALL_CPP=1 $PYTHON_EXE setup.py bdist_wheel
  73. mv dist/*.whl ../.whl/
  74. popd
  75. done