build-wheel-manylinux2014.sh 3.9 KB

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