build-wheel-manylinux2014.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/bin/bash
  2. set -x
  3. # Cause the script to exit if a single command fails.
  4. set -euo pipefail
  5. cat << EOF > "/usr/bin/nproc"
  6. #!/bin/bash
  7. echo 10
  8. EOF
  9. chmod +x /usr/bin/nproc
  10. NODE_VERSION="14"
  11. PYTHONS=("cp37-cp37m"
  12. "cp38-cp38"
  13. "cp39-cp39"
  14. "cp310-cp310"
  15. "cp311-cp311")
  16. NUMPY_VERSIONS=("1.14.5"
  17. "1.14.5"
  18. "1.19.3"
  19. "1.22.0"
  20. "1.22.0")
  21. yum -y install unzip zip sudo
  22. yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel xz
  23. yum -y install openssl
  24. if [ "${HOSTTYPE-}" = "x86_64" ]; then
  25. yum install "libasan-4.8.5-44.el7.${HOSTTYPE}" -y
  26. yum install "libubsan-7.3.1-5.10.el7.${HOSTTYPE}" -y
  27. yum install "devtoolset-8-libasan-devel.${HOSTTYPE}" -y
  28. fi
  29. java -version
  30. java_bin=$(readlink -f "$(command -v java)")
  31. echo "java_bin path $java_bin"
  32. java_home=${java_bin%jre/bin/java}
  33. export JAVA_HOME="$java_home"
  34. /ray/ci/env/install-bazel.sh
  35. # Put bazel into the PATH if building Bazel from source
  36. # export PATH=/root/bazel-3.2.0/output:$PATH:/root/bin
  37. # If converting down to manylinux2010, the following configuration should
  38. # be set for bazel
  39. #echo "build --config=manylinux2010" >> /root/.bazelrc
  40. echo "build --incompatible_linkopts_to_linklibs" >> /root/.bazelrc
  41. if [[ -n "${RAY_INSTALL_JAVA:-}" ]]; then
  42. bazel build //java:ray_java_pkg
  43. unset RAY_INSTALL_JAVA
  44. fi
  45. # Install and use the latest version of Node.js in order to build the dashboard.
  46. set +x
  47. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
  48. source "$HOME"/.nvm/nvm.sh
  49. nvm install "$NODE_VERSION"
  50. nvm use "$NODE_VERSION"
  51. # Build the dashboard so its static assets can be included in the wheel.
  52. # TODO(mfitton): switch this back when deleting old dashboard code.
  53. pushd python/ray/dashboard/client
  54. npm ci
  55. npm run build
  56. popd
  57. set -x
  58. # Add the repo folder to the safe.dictory global variable to avoid the failure
  59. # because of secruity check from git, when executing the following command
  60. # `git clean ...`, while building wheel locally.
  61. git config --global --add safe.directory /ray
  62. mkdir -p .whl
  63. for ((i=0; i<${#PYTHONS[@]}; ++i)); do
  64. PYTHON=${PYTHONS[i]}
  65. NUMPY_VERSION=${NUMPY_VERSIONS[i]}
  66. # The -f flag is passed twice to also run git clean in the arrow subdirectory.
  67. # The -d flag removes directories. The -x flag ignores the .gitignore file,
  68. # and the -e flag ensures that we don't remove the .whl directory, the
  69. # dashboard directory and jars directory.
  70. git clean -f -f -x -d -e .whl -e python/ray/dashboard/client -e dashboard/client -e python/ray/jars
  71. pushd python
  72. # Fix the numpy version because this will be the oldest numpy version we can
  73. # support.
  74. /opt/python/"${PYTHON}"/bin/pip install -q numpy=="${NUMPY_VERSION}" cython==0.29.32
  75. # Set the commit SHA in __init__.py.
  76. if [ -n "$TRAVIS_COMMIT" ]; then
  77. sed -i.bak "s/{{RAY_COMMIT_SHA}}/$TRAVIS_COMMIT/g" ray/__init__.py && rm ray/__init__.py.bak
  78. else
  79. echo "TRAVIS_COMMIT variable not set - required to populated ray.__commit__."
  80. exit 1
  81. fi
  82. # build ray wheel
  83. PATH=/opt/python/${PYTHON}/bin:/root/bazel-3.2.0/output:$PATH \
  84. /opt/python/"${PYTHON}"/bin/python setup.py bdist_wheel
  85. # build ray-cpp wheel
  86. PATH=/opt/python/${PYTHON}/bin:/root/bazel-3.2.0/output:$PATH \
  87. RAY_INSTALL_CPP=1 /opt/python/"${PYTHON}"/bin/python setup.py bdist_wheel
  88. # In the future, run auditwheel here.
  89. mv dist/*.whl ../.whl/
  90. popd
  91. done
  92. # Rename the wheels so that they can be uploaded to PyPI. TODO(rkn): This is a
  93. # hack, we should use auditwheel instead.
  94. for path in .whl/*.whl; do
  95. if [ -f "${path}" ]; then
  96. out="${path//-linux/-manylinux2014}"
  97. if [ "$out" != "$path" ]; then
  98. mv "${path}" "${out}"
  99. fi
  100. fi
  101. done
  102. # Clean the build output so later operations is on a clean directory.
  103. git clean -f -f -x -d -e .whl -e python/ray/dashboard/client