diff --git a/.travis.yml b/.travis.yml index 99d119366..8ad21aaf5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -144,7 +144,7 @@ matrix: # This command should be kept in sync with ray/python/README-building-wheels.md, # except the `$MOUNT_BAZEL_CACHE` part. - - ./ci/suppress_output docker run --rm -w /ray -v `pwd`:/ray $MOUNT_BAZEL_CACHE -ti rayproject/arrow_linux_x86_64_base:ARROW-5631 /ray/python/build-wheel-manylinux1.sh + - ./ci/suppress_output docker run -e TRAVIS_COMMIT=$TRAVIS_COMMIT --rm -w /ray -v `pwd`:/ray $MOUNT_BAZEL_CACHE -ti rayproject/arrow_linux_x86_64_base:ARROW-5631 /ray/python/build-wheel-manylinux1.sh script: - if [ $RAY_CI_LINUX_WHEELS_AFFECTED != "1" ]; then exit; fi diff --git a/ci/travis/test-wheels.sh b/ci/travis/test-wheels.sh index 3314f221a..e9e3e258d 100755 --- a/ci/travis/test-wheels.sh +++ b/ci/travis/test-wheels.sh @@ -40,6 +40,9 @@ if [[ "$platform" == "linux" ]]; then # Install the wheel. $PIP_CMD install -q "$PYTHON_WHEEL" + # Check that ray.__commit__ was set properly. + $PYTHON_EXE -u -c "import ray; print(ray.__commit__)" | grep $TRAVIS_COMMIT || (echo "ray.__commit__ not set properly!" && exit 1) + # Run a simple test script to make sure that the wheel works. INSTALLED_RAY_DIRECTORY=$(dirname "$($PYTHON_EXE -u -c "import ray; print(ray.__file__)" | tail -n1)") $PYTHON_EXE "$TEST_SCRIPT" diff --git a/python/build-wheel-macos.sh b/python/build-wheel-macos.sh index 74e9ca79c..7960866b7 100755 --- a/python/build-wheel-macos.sh +++ b/python/build-wheel-macos.sh @@ -79,6 +79,13 @@ for ((i=0; i<${#PY_VERSIONS[@]}; ++i)); do $PIP_CMD install -q numpy==$NUMPY_VERSION cython==0.29.0 # Install wheel to avoid the error "invalid command 'bdist_wheel'". $PIP_CMD install -q wheel + # Set the commit SHA in __init__.py. + if [ -n "$TRAVIS_COMMIT" ]; then + sed -i.bak "s/{{RAY_COMMIT_SHA}}/$TRAVIS_COMMIT/g" ray/__init__.py && rm ray/__init__.py.bak + else + echo "TRAVIS_COMMIT variable not set - required to populated ray.__commit__." + exit 1 + fi # Add the correct Python to the path and build the wheel. This is only # needed so that the installation finds the cython executable. PATH=$MACPYTHON_PY_PREFIX/$PY_MM/bin:$PATH $PYTHON_EXE setup.py bdist_wheel diff --git a/python/build-wheel-manylinux1.sh b/python/build-wheel-manylinux1.sh index 04aecf135..ea4926c77 100755 --- a/python/build-wheel-manylinux1.sh +++ b/python/build-wheel-manylinux1.sh @@ -28,6 +28,7 @@ sudo apt-get install unzip export PATH=$PATH:/root/bin # Install and use the latest version of Node.js in order to build the dashboard. +set +x curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash source $HOME/.nvm/nvm.sh nvm install node @@ -38,6 +39,7 @@ pushd python/ray/dashboard/client npm ci npm run build popd +set -x mkdir .whl for ((i=0; i<${#PYTHONS[@]}; ++i)); do @@ -54,6 +56,14 @@ for ((i=0; i<${#PYTHONS[@]}; ++i)); do # Fix the numpy version because this will be the oldest numpy version we can # support. /opt/python/${PYTHON}/bin/pip install -q numpy==${NUMPY_VERSION} cython==0.29.0 + # Set the commit SHA in __init__.py. + if [ -n "$TRAVIS_COMMIT" ]; then + sed -i.bak "s/{{RAY_COMMIT_SHA}}/$TRAVIS_COMMIT/g" ray/__init__.py && rm ray/__init__.py.bak + else + echo "TRAVIS_COMMIT variable not set - required to populated ray.__commit__." + exit 1 + fi + PATH=/opt/python/${PYTHON}/bin:$PATH /opt/python/${PYTHON}/bin/python setup.py bdist_wheel # In the future, run auditwheel here. mv dist/*.whl ../.whl/ diff --git a/python/ray/__init__.py b/python/ray/__init__.py index 9874d36c2..d813f226e 100644 --- a/python/ray/__init__.py +++ b/python/ray/__init__.py @@ -98,7 +98,8 @@ from ray.runtime_context import _get_runtime_context # noqa: E402 from ray.cross_language import java_function, java_actor_class # noqa: E402 from ray import util # noqa: E402 -# Ray version string. +# Replaced with the current commit when building the wheels. +__commit__ = "{{RAY_COMMIT_SHA}}" __version__ = "0.9.0.dev0" __all__ = [