build-wheel-manylinux2014.sh 3.5 KB

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